<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Raspberry | blog.moe.ph</title><link>https://blog.moe.ph/tags/raspberry/</link><atom:link href="https://blog.moe.ph/tags/raspberry/index.xml" rel="self" type="application/rss+xml"/><description>Raspberry</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Sun, 05 Jan 2020 00:00:00 +0000</lastBuildDate><image><url>https://blog.moe.ph/media/logo_hu_230979b687bad52e.png</url><title>Raspberry</title><link>https://blog.moe.ph/tags/raspberry/</link></image><item><title>Raspberry Pi 3 with Separate Power Supply on SIM800L</title><link>https://blog.moe.ph/blog/raspberry-pi-3-with-separate-power-supply-on-sim800l/</link><pubDate>Sun, 05 Jan 2020 00:00:00 +0000</pubDate><guid>https://blog.moe.ph/blog/raspberry-pi-3-with-separate-power-supply-on-sim800l/</guid><description>&lt;p&gt;After initial testing with SIM800L without separate power supply, I explored a bit and bought additional components for my testing.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DC Buck Converter&lt;/li&gt;
&lt;li&gt;12V 1A DC Adapter&lt;/li&gt;
&lt;li&gt;DC Jack Barrel&lt;/li&gt;
&lt;li&gt;Alligator Clips&lt;/li&gt;
&lt;li&gt;Male to Female Jumper Wires&lt;/li&gt;
&lt;li&gt;Quad-band Wired Cellular Antenna&lt;/li&gt;
&lt;li&gt;Digital Multimeter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To set this all up, I assume that you already setup the GSM module with RPI3. We will just setup the power supply side of it.&lt;/p&gt;
&lt;h2 id="part-1"&gt;Part 1&lt;/h2&gt;
&lt;p&gt;Connect the DC barrel jack with the 12V DC Adapter. Connect the DC barrel jack to DC buck converter using alligator clips. Then plug the DC adapter to outlet.&lt;/p&gt;
&lt;p&gt;Check if the buck converter is powered on after plugging in. It has a LED indicator, so it should lit up.&lt;/p&gt;
&lt;p&gt;We should setup the voltage output of the buck converter to 5V. To do this, you will see a screw on top of the blue part of the buck converter. Use multimeter to monitor it&amp;rsquo;s current voltage on the output, then turn the screw. Adjust it accordingly until it reads within ~5V area.&lt;/p&gt;
&lt;h2 id="part-2"&gt;Part 2&lt;/h2&gt;
&lt;p&gt;Plug out the power supply for now. Get some male to female jumper wires. Connect the female jumpers to 5VIN and GND. After that, connect the male jumper of 5VIN with the out+ of the buck converter. Connect the male jumper of GND to out-. For solderless setup, I just use an extra alligator just to keep the male jumper in place.&lt;/p&gt;
&lt;p&gt;Once it&amp;rsquo;s done, power-on your RPI3 first, then plug in the power of the GSM module. The GSM module should blink now, indicating that it&amp;rsquo;s already power on.&lt;/p&gt;
&lt;div class="callout flex px-4 py-3 mb-6 rounded-md border-l-4 bg-blue-100 dark:bg-blue-900 border-blue-500"
data-callout="note"
data-callout-metadata=""&gt;
&lt;span class="callout-icon pr-3 pt-1 text-blue-600 dark:text-blue-300"&gt;
&lt;svg height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"&gt;&lt;path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m16.862 4.487l1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8l.8-2.685a4.5 4.5 0 0 1 1.13-1.897zm0 0L19.5 7.125"/&gt;&lt;/svg&gt;
&lt;/span&gt;
&lt;div class="callout-content dark:text-neutral-300"&gt;
&lt;div class="callout-title font-semibold mb-1"&gt;Note&lt;/div&gt;
&lt;div class="callout-body"&gt;&lt;p&gt;If you noticed that the GSM module is suddenly turning off, then turn on, you might need to adjust the output of the buck converter. It usually happen when there&amp;rsquo;s not enough power, or too much voltage to the GSM module.&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="part-3"&gt;Part 3&lt;/h2&gt;
&lt;p&gt;Test the connection to the GSM module now. You should be able to connect to it seamlessly now.&lt;/p&gt;
&lt;h2 id="part-4-bonus"&gt;Part 4 (Bonus)&lt;/h2&gt;
&lt;p&gt;Since we have more power to our GSM, we should use that power to get more signal. To have more signal, use a longer cellular antenna. Just make sure that it has SMA connector.&lt;/p&gt;
&lt;p&gt;To connect it, just remove the default antenna provided with GSM module, then put the new antenna.&lt;/p&gt;</description></item><item><title>SIM800L Integration with Raspberry Pi 3</title><link>https://blog.moe.ph/blog/sim800l-integration-with-raspberry-pi-3/</link><pubDate>Tue, 17 Dec 2019 00:00:00 +0000</pubDate><guid>https://blog.moe.ph/blog/sim800l-integration-with-raspberry-pi-3/</guid><description>&lt;p&gt;In this past few days, I bought some IOT modules since I have a lying RPi3 around. I bought this RPi3 around 2016 to make a media box. Since I&amp;rsquo;m not using it as much as of now, I decided to tinker with it. One of the module that caught my attention was SIM800L module. It&amp;rsquo;s only cheap, so I guess why not?&lt;/p&gt;
&lt;p&gt;So here&amp;rsquo;s my TL;DR in setting it up.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Download and install the latest copy of Rasbpian to microSD.&lt;/li&gt;
&lt;li&gt;Setup RPi to be able to use serial pins.&lt;/li&gt;
&lt;li&gt;Connect the SIM800L to RPi GPIOs.&lt;/li&gt;
&lt;li&gt;Test the serial connection to the module.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&amp;rsquo;s the needed peripherals to be able to finish the setup.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;RPi3&lt;/li&gt;
&lt;li&gt;MicroSD (16GB)&lt;/li&gt;
&lt;li&gt;SIM800L Module&lt;/li&gt;
&lt;li&gt;5 Female-to-Female pins&lt;/li&gt;
&lt;li&gt;SIM Card&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="part-1"&gt;Part 1&lt;/h2&gt;
&lt;p&gt;To start, go and download the latest image of Rasbian from Raspberry official site. Just download the Raspian Buster Lite version, or go with the desktop one if you&amp;rsquo;re planning to connect it to TV or monitor.&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;After downloading, extract it. Then flash it to your flash disk. You can just use &amp;ldquo;dd&amp;rdquo; image utility, since it&amp;rsquo;s pretty easy. Please take note that everything will be overwritten on the microSD card.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;dd if=[RASPBIAN IMAGE] of=/dev/[MICROSD CARD] bs=4M
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After flashing it, go and put it to the RPi. It would be much better if you can connect the RPi to monitor or TV for some initial setup. Upon checking, it seems that SSHD service is not enabled by default. You would need to enable it for easier access to the Pi. It would also be best if you can connect it to your network via ethernet port.&lt;/p&gt;
&lt;h2 id="part-2"&gt;Part 2:&lt;/h2&gt;
&lt;p&gt;Go boot your RPi. Once the server has been successfully booted, login into the server using this credentials.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Username: pi&lt;/li&gt;
&lt;li&gt;Password: raspberry&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After that, go and set-up these things below.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Enable SSHD service.&lt;/li&gt;
&lt;li&gt;Upgrade the system to the latest version&lt;/li&gt;
&lt;li&gt;Disable serial console of the RPi.&lt;/li&gt;
&lt;li&gt;Enable UART.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Run the command below to enable sshd and do system upgrade if needed.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo systemctl enable sshd &amp;amp;&amp;amp; sudo systemctl start sshd
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade -y
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To disable the serial console, go run the command below. Then go to Option 5 - Interfacing Options. Go to P6 - Serial. Disable both the login shell, and the serial port hardware.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;raspi-config
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To enable UART, add the &amp;rsquo;enable_uart=1&amp;rsquo; parameter to &amp;lsquo;/boot/config.txt&amp;amp;&amp;rsquo; file.&lt;/p&gt;
&lt;p&gt;After setting everything up, go and power-off the RPi.&lt;/p&gt;
&lt;h2 id="part-3"&gt;Part 3&lt;/h2&gt;
&lt;p&gt;Get your 5 pins. There are 5 pins that should be connected from the SIM800L module to RPi. Just make sure that RPi is off before connecting the pins. Be better sure than having a fried RPi board. Connect the SIM card as well before putting the pins.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;5V Input (SIM) &amp;gt; 5V Pin (RPi)&lt;/li&gt;
&lt;li&gt;Power Ground (SIM) &amp;gt; Ground (RPi)&lt;/li&gt;
&lt;li&gt;RX Pin (SIM) &amp;gt; TX Serial Pin - GPIO 14 (RPi)&lt;/li&gt;
&lt;li&gt;TX Pin (SIM) &amp;gt; RX Serial Pin - GPIO 15 (RPi)&lt;/li&gt;
&lt;li&gt;Data Ground (SIM) &amp;gt; Ground (RPi)&lt;/li&gt;
&lt;li&gt;I&amp;rsquo;m not really sure about the RST Pin on the SIM800L, but it seems that it&amp;rsquo;s not needed yet.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="callout flex px-4 py-3 mb-6 rounded-md border-l-4 bg-blue-100 dark:bg-blue-900 border-blue-500"
data-callout="note"
data-callout-metadata=""&gt;
&lt;span class="callout-icon pr-3 pt-1 text-blue-600 dark:text-blue-300"&gt;
&lt;svg height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"&gt;&lt;path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m16.862 4.487l1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8l.8-2.685a4.5 4.5 0 0 1 1.13-1.897zm0 0L19.5 7.125"/&gt;&lt;/svg&gt;
&lt;/span&gt;
&lt;div class="callout-content dark:text-neutral-300"&gt;
&lt;div class="callout-title font-semibold mb-1"&gt;Note&lt;/div&gt;
&lt;div class="callout-body"&gt;&lt;p&gt;There&amp;rsquo;s a lot of recommendation to have a separate power supply for SIM800L module, but since I don&amp;rsquo;t have those tools yet, I dared to connect it directly to RPi GPIOs. I didn&amp;rsquo;t have any issues yet as of writing this post. Separate power supply might be needed if you&amp;rsquo;re planning to connect to Internet while the RPi is up.&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="callout flex px-4 py-3 mb-6 rounded-md border-l-4 bg-blue-100 dark:bg-blue-900 border-blue-500"
data-callout="note"
data-callout-metadata=""&gt;
&lt;span class="callout-icon pr-3 pt-1 text-blue-600 dark:text-blue-300"&gt;
&lt;svg height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"&gt;&lt;path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m16.862 4.487l1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8l.8-2.685a4.5 4.5 0 0 1 1.13-1.897zm0 0L19.5 7.125"/&gt;&lt;/svg&gt;
&lt;/span&gt;
&lt;div class="callout-content dark:text-neutral-300"&gt;
&lt;div class="callout-title font-semibold mb-1"&gt;Note&lt;/div&gt;
&lt;div class="callout-body"&gt;&lt;p&gt;Actually tested using the GSM module with Gammu and PPP, and it didn&amp;rsquo;t work as much. After testing with separate power supply, the module work as expected. It does need separate power supply.&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Once everything is connected, go and power it on. Once the RPi is on, the module&amp;rsquo;s light should be on. There&amp;rsquo;s a separate blinking light indicator for the network connection.&lt;/p&gt;
&lt;h2 id="part-4"&gt;Part 4&lt;/h2&gt;
&lt;p&gt;You need to confirm now if the SIM800L is responding to serial commands. To test it, I just use a pyserial module from Python. You can also use minicom tool, but I think I&amp;rsquo;m having issues using it.&lt;/p&gt;
&lt;p&gt;You can download the needed module using the command below.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt-get install -y python3-pip &amp;amp;&amp;amp; sudo pip3 install pyserial
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once downloaded, you can use this code to test the serial connection. Save it as &amp;lsquo;at-command.py&amp;rsquo;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#This is the pyserial module
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;import serial
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Enable Serial Communication
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# You may need to change the ttyS0 device and baudrate, but it worked in my case.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;port = serial.Serial(&amp;#34;/dev/ttyS0&amp;#34;, baudrate=115200, timeout=1)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Transmitting AT Commands to the Modem
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# &amp;#39;\r\n&amp;#39; indicates the Enter key
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;port.write(b&amp;#39;AT\r\n&amp;#39;)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;rcv = port.read(10)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;print(rcv)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then run the script using the command below.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo python3 at-command.py
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The command should print something like this.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;b&amp;#39;AT\r\r\nOK\r\n&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once you confirmed that the serial command is printing OK result, you can now successfully connect to the SIM800L module!&lt;/p&gt;
&lt;p&gt;Congratulations, you can now use the SIM800L module to connect to Internet via ppp or send and receive sms using gammu. For these use cases, I&amp;rsquo;ll create another post for those.&lt;/p&gt;
&lt;h2 id="troubleshooting-notes"&gt;Troubleshooting Notes&lt;/h2&gt;
&lt;p&gt;The at-command.py didn&amp;rsquo;t generate an OK result.&lt;/p&gt;
&lt;p&gt;You might confused the RX and TX connections between the SIM800L module and RPi. You need to connect the RX of module to TX of RPi, and vice versa. It&amp;rsquo;s easy to encounter this issue, since I experienced it myself.&lt;/p&gt;
&lt;h2 id="to-do"&gt;To Do&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;I&amp;rsquo;ll add setup photos later.&lt;/li&gt;
&lt;li&gt;Add the references links.&lt;/li&gt;
&lt;li&gt;Create another post for pppd and gammu setup.&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>