This week’s Weekly Roundup is chock full of SBCs and I’m not going to mention that word that flags my videos with YouTube as being inappropriate. Kickstarter First up on Kickstarter … EEVblog 121GW Multimeter Dave Jones from EEVBlog has an upgrade on his popular multi-meter. In conjunction with UEI Continue reading Weekly Roundup #48: New Maker Products
Limpkin published a new build:
For once, this project was not for me… it was for my wife !
Every morning she takes the bus then train to go to work. If she misses her train, she has to wait for more than 30 minutes for the next one. Not missing her bus is therefore quite important.
Where we live every bus station has a display letting you know in real time when the next bus will be there. My first thought was to reverse engineer its RF signal but something easier then came to mind.
In the very same bus stations, a small QR code brings you to a web page displaying the very same “minutes before bus arrival”… HTML parsing therefore made more sense given that I was fairly busy with other projects.
See the full post on his blog.
Security is a very important aspect for MQTT brokers. In a previous article you’ve already learned how to implement authentication and authorization. The weakness in that configuration was that credentials were transmitted in cleartext; it was therefore possible, for an attacker who can sniff the network traffic, to read and use them to impersonate a legitimate client.
Today I’ll show you how to encrypt the communication channel between client and broker using SSL certificates. I’ll also explain how to write a program for the esp32 chip to send data to the broker using the secure channel…
To be able to encrypt the communication, mosquitto requires a server certificate.
First generate the private key (RSA with a length at least 2048 bits):
openssl genrsa -out mosquitto.key 2048
Then create the CSR file:
openssl req -new -out mosquitto.csr -key mosquitto.key
type the required information; the most important of which is the common name that will identify the server:
Now sign the CSR file with your Certificate Authority (or send it to a public / corporate CA) to generate the certificate:
openssl ca -config openssl.cnf -extensions server_cert -notext -in mosquitto.csr -out mosquitto.cer
Create the ssl subfolder in the folder where you installed mosquitto and copy into that folder the certificate, its private key and the certificate of the CA:
Open the mosquitto.conf file and add the following lines:
The first line changes the TCP port mosquitto is normally listening to (1883) to the default port for SSL connection, 8883.
The following 3 lines set the path for server and CA certificates and for the private key that corresponds to the server certificate. The last one, which is not compulsory, forces the use of the TLS v1.2 protocol, the most secure one at the moment of writing.
Once the server has been configured, you can start it (-v is to enable the verbose output):
mosquitto.exe -c mosquitto.conf -v
To be able to use the mosquitto_pub and mosquitto_sub tools, you now have to add new parameters:
mosquitto_sub.exe -p 8883 -t test --cafile .\ssl\ca.cer --insecure mosquitto_pub.exe -p 8883 -m 20 -t test --cafile .\ssl\ca.cer --insecure
With -p you specify the TCP port of the server, with –cafile the path of the CA certificate which signed the server certificate mosquitto uses and finally with –insecure you configure the two clients not to verify that the certificate’s common name (in my example mymosquitto.local) corresponds to the server name.
Tuan PM developed a library (espmqtt) for the esp-idf framework that implements a complete MQTT client. Moreover, the library does support secure connections, you can therefore use it to connect to an MQTT broker with TLS enabled.
Copy the content of the Github repository in the components folder of your project and include the library’s header file in your source code:
The MQTT client is configured using the mqtt_settings struct:
The most important parameters are:
- the server (host) that runs the MQTT broker (you can use the IP address or the DNS name)
- the TCP port (port) the server is listening to (default is 1883 or 8883 if SSL is enabled)
- username and password if the server requires authentication
- one or more callback functions the espmqtt library will call when the corresponding event occurs
Your program can interact with the MQTT client implementing its callback functions.
For example the connection or disconnection from the MQTT server occurs as follows:
The connect_cb and disconnect_cb functions perform the “real” connection and disconnection, while connected_cb and disconnected_cb functions are executed after the corresponding activity is completed (= the client successfully connected to the server). Your program usually doesn’t need to re-implement the main functions, but will implement the ones related to events, to execute actions (for example subscribe a topic) when a specific event occurs.
After having configured the client, you can run it with:
Once connected to the server (connected_cb callback function) you can subscribe or unsubscribe a topic with:
void mqtt_subscribe(mqtt_client *client, const char *topic, uint8_t qos); void mqtt_unsubscribe(mqtt_client *client, const char *topic);
and publish data to a topic with:
void mqtt_publish(mqtt_client* client, const char *topic, const char *data, int len, int qos, int retain);
I prepared an example to show my esp32 devboard sending data to a mosquitto server, with SSL enabled.
I connected to the devboard an HTU21D sensor as explained in a previous article and my program reads, every 5 seconds, the temperature and humidity values and sends them to the broker. I used a very handy opensource program, HelloIoT, to create a dashboard and display the received data.
The source code of the program and the configuration of the HelloIoT dashboard are available in my Github repository; here’s a short video of the demo:
App note from STMicroelectronics about current sensing using Rogowski coil together with STPMxx metering device. Link here (PDF)
This application note describes the benefits of a current sensing system for metering applications using STPMxx metering devices and a current sensor developed by Pulse Engineering Inc. (hereafter referred to as “Pulse current sensor”), based on the Rogowski coil principle. Following an overview of the Rogowski coil principle, the Pulse current sensor is introduced along with a comparison to other current measuring devices. This is followed by a presentation of the characteristics of the STPMxx family of metering devices, and the results of accuracy testing conducted using a demonstration board with the STPM01 and the Pulse current sensor.
ARM Microcontroller based watt-hour meter implementation from STMicroelectronics. Link here (PDF)
This document describes, in detail, the hardware and software implementation of a watthour meter using the STM32F101 microcontroller. This cost effective watt-hour meter uses shunt with an operational amplifier as a current sensor, an embedded 12-bit ADC for current and voltage measurement, GPIO for LCD management, and a lot of other peripherals for communication, tamper detection, keyboard, and power disconnection. Powerful architecture of the STM32™ microcontroller allows sampling at 1 Msps. The high sampling rate makes it possible to use methods for ADC resolution enhancement.
So, you’ve gotten to the stage where you want to build your own PCB? This is a two part video taking a look at EasyEDA who seem to be doing a good job of making things easy for you. Current offerings There’s a lot of online PCB manufacturing companies. Huge Continue reading Making a PCB using EasyEDA. // Review
After a bit of a hiatus MickMake is back with another mailbag. This time there’s some Tindie goodies for the winners of the MickMake/Tindie competition, also a GroupGets backed #LoFive, #IkaScope hi-res photo update and a short look at the #Rock64 and #BananaPiM2Berry. Tindie goodies Jasmine, (the top dog of Continue reading MickMake Mail #22: LoFive, Tindie and a lot of trouble // News
Mare published a new build:
This is complete project for 1×6 antenna switch. It was bult in more than 50 pieces around the world and performs really good. Even big guns use it for their systems. The project was designed with help from other OMs (S55O, S59MA, S50LD, S51CT, S51ZJ, SM2WMV/SJ2W and others).
More details at Mare & Gal Electronics.
Steve documented his experience experimenting with home weather logging:
Like a million other people on the Internet, I’ve been experimenting with home weather logging. I roll my eyes at the phrase “Internet of Things”, but it’s hard to deny the potential of cheap networked sensors and switches, and a weather logging system is like this field’s Hello World application. Back in June I posted about my initial experiments in ESP8266 weather logging. Since then I’ve finalized the hardware setup, installed multiple nodes around the house, organized a nice web page to analyze all the data, and integrated everything with Amazon Alexa. Time for an update.
More details at Big Mess o’ Wires homepage.
Check out the video after the break.