Archive for the ‘LoRa’ Category

Solar-Powered LoRa Weather Station

Project source code at GitHub: lora-weather-station

In this project I show how I built a remote, solar-powered weather station that transmits temperature and humidity readings over LoRa, and a base station that publishes the data to the Internet with MQTT (er, I guess we are supposed to say “cloud” now).



LoRa (Long Range) is a relatively new radio technology intended for reliable communication of small amounts of data over distances that are longer than achievable with bluetooth or Wi-Fi. It’s also geared toward low power applications. LoRa modules are relatively cheap (about $8 for a bare module), but the easiest way to use LoRa is to buy development boards that also have a microcontroller on them. Moteino and Anarduino MiniWireless both have LoRa enabled transceivers that work well and are essentially the same. Each is basically a small Arduino with ATmega328 and LoRa module. They cost around $20-25, and remember that you’ll need 2 of them, one for each end of the communication.

Weather Station

The remote weather monitoring station has a cheap solar panel, a LiPo battery, an Adafruit LiPo charging board, and an an Anarduino board with a TH02 I2C temperature and humidity sensor. I enclosed all of this in an small plastic box (not waterproof!).



Reading the I2C sensor is easily accomplished using this TH02 library. As for the control of the LoRa radio, there is a wonderful library called RadioHead that makes it easy to use all kinds of radio technology in embedded systems. For message format, I like to use JSON because it is easy to read and very flexible. The ArduinoJson is an excellent Arduino library for generating and parsing JSON strings. Using these 3 libraries, the Arduino sketch reads the sensor and transmits a small JSON message with the temperature and humidity readings to the base station every 10 seconds. The format of the JSON message is simple:

{
  temp: 72.1,
  hum: 54.2
}

Base Station

The base station has 2 hardware modules. First, there is another LoRa module to receive the sensor reading messages. When the LoRa module receives the JSON message from the weather station, it simply writes the message over the serial UART which is connected to the second board, an IoT Experimenter development board. The IoT Experimenter has an ESP8266 WiFi microcontroller which provides a gateway to the Internet. I designed the IoT Experimenter as a simple tool for my IoT projects, and you can read more about the IoT Experimenter here. You can connect an OLED display which allows us to see the data right at the base station.



The code on the IoT Experimenter receives the message over serial and publishes the data using MQTT. In the source code for the ESP8266 you will need to add your WiFi user/password, as well as the info about an MQTT broker to publish the data to. You can set up a free account on CloudMQTT. Their free plan allows you to have up to 10 connections. The source code for this project makes it clear where to set the information for your account: username, password, server, and port. This project uses an SSL connection, so use the SSL port on your CloudMQTT server.

Instead of watching the weather data on the base station’s OLED display, it is more convenient to see it on the Internet or on your phone. I have an Android phone and use a simple app called MQTT Dash. It lets you create dashboards with controls on them. My weather dashboard has gauges for the temperature and humidity.

MQTT Dashboard on Android



Another way to see data from an MQTT broker is to use the Chrome app called MQTTLens. It allows you to connect to an MQTT broker, publish to topics and subscribe to topics. It works well.

Project source code at GitHub: lora-weather-station


Published by Michael, on September 3rd, 2017 at 8:44 am. Filed under: ESP8266,IoT,LoRa. | No Comments |

Introducing the IoT Experimenter ESP8266 Development Board

Like many other hardware hackers, I fell in love with the ESP8266 Wi-Fi microcontroller as soon as I started using it. It is fast, has plenty of memory, has Wi-Fi networking, and can be programmed in a number of ways. Lots of people like the Lua firmware, but I prefer to use the ESP8266 core for Arduino because I can use all the great libraries already built for Arduino.

I’m also working with LoRa radio technology. Several small Arduino-based boards are available for experimenting with LoRa: Moteino and Anarduino MiniWireless have LoRa capable boards that are easy to use. They both have the standard 6-pin serial connection for easy programming. What I really wanted to do is combine long range radio technology with Wi-Fi connectivity, so I designed an ESP8266 Development board that allows for easy connection of a LoRa radio module. While I was at it, I also included connectivity for an OLED display, ArduCAM camera module, and included a nice big PL9823 RGB LED that can be controlled just like WS2812 LEDs.

IoT Experimenter ESP8266 development board



There’s also connection for analog input with a voltage divider to scale voltage down to the 1V ranged required by the ESP8266. The board has 2 voltage regulators: a 3.3V one for the ESP8266, and a 5V regulator for powering the RGB LED and to provide power to the radio module header. If you are wondering how I drive a 5V LED with 3.3V logic from the ESP, a diode in line with the LED’s power supply drops the VCC low enough for 3.3V logic to work reliably. I learned that clever trick from this Hackaday article. If you want to connect a strip of WS2812 LEDs, there are pads for that, too.

The TX/RX serial lines for the radio module and ESP8266 are connected together for simple serial communication. This makes it easy to build a simple radio to Internet gateway. See my project Solar-Powered LoRa Weather Station for a good example of this approach. Also, this header can be used for any kind of radio (not just LoRa) that has a 6-pin header with the standard FTDI pinout. In fact, it doesn’t have to be a radio at all! Communication with any serial device might be just what you need.

Radio module attached to IoT Experimenter





The ArduCAM camera module for Arduino works great with the ESP8266 (here is the library) so I can make surveillance cameras with this board. The 8-pin female header for the camera is on the underside of the board and the camera fits great right on top of the board.

ArduCAM module attached to IoT Experimenter





I also love those cheap I2C OLED displays. They come in several colors and are only a few dollars. So I added a header for that also. It’s great for debugging, and when you are done, just pull the display off.

OLED display attached to IoT Experimenter





The PL9823 RGB LED can be controlled using any WS2812 library, like the Adafruit NeoPixel library. This big 8mm LED looks great. Make it any color you want!

RGB LED



This board has proven really useful for me in several projects, and I’m probably going to offer it as a product. Hope you like it, and if you are interested, let me know.


Published by Michael, on September 3rd, 2017 at 8:42 am. Filed under: Arduino,ESP8266,IoT,LoRa. | No Comments |