Using MQTT with the Raspberry Pi Pico W and HomeAssistant for an Optimized Solar Energy Electrical Vehicle Charger

I’m in the final stage of finishing a electrical vehicle (EV) charger controller, which optimizes battery loading using the available PV system: use as much as possible the solar energy and not the grid.

Raspberry Pi Pico W as a EV Charger Controller

While the controller talks with an Modbus (RS-485) interface to the vehicle charger itself (see Controlling an EV Charger with Modbus RTU), it uses MQTT over WiFi to get information about the available solar energy from HomeAssistant and the Powerwall.

Continue reading

Tuturial: mbedTLS SSL Certificate Verification with Mosquitto, lwip and MQTT

In “Tutorial: Secure TLS Communication with MQTT using mbedTLS on top of lwip” I already used TLS for a secure communication, but I had not enabled server certificate verification. This article is about closing that gap.

MQTT running on NXP FRDM-K64F

Secure MQTT running on NXP FRDM-K64F with lwip and mbed TLS

Continue reading

Tutorial: Secure TLS Communication with MQTT using mbedTLS on top of lwip

One of the most important aspects of the ‘IoT’ world is having a secure communication. Running MQTT on lwip (see “MQTT with lwip and NXP FRDM-K64F Board“) is no exception. Despite of the popularity of MQTT and lwip, I have not been able to find an example using a secure TLS connection over raw/native lwip TCP :-(. Could it be that such an example exists, and I have not found it? Or that someone implemented it, but has not published it? Only what I have found on the internet are many others asking for the same kind of thing “running MQTT on lwip with TLS”, but there was no answer? So I have to answer my question, which seems to be a good thing anyway: I can learn new things the hard way :-).

Blockdiagram MQTT Application with TLS using lwip

Block diagram MQTT Application with TLS using lwip

Continue reading

Enable Secure Communication with TLS and the Mosquitto Broker

MQTT is a lightweight  and broadly used internet protocol (see “MQTT with lwip and NXP FRDM-K64F Board“). And probably the majority of IoT applications today are using Mosquitto as server (or ‘broker’ in MQTT language). By default, Mosquitto is using a protocol without encryption. In “Introduction to Security and TLS (Transport Layer Security)” I have covered the basics and needs for encryption. This article is about how to enable Mosquitto and clients to use the TLS protocol.

TLS Handshaking with certificates and keys

TLS Handshaking with certificates and keys

Continue reading

Introduction to Security and TLS (Transport Layer Security)

IoT (Internet of Things) is all about connecting to the internet. And even more it is about security. Without security and without encrypted communication, everyone possibly can see what I send or receive. And this is especially bad if passwords or user names are sent in an unencrypted way. So encryption and secure communication is key. The solution to that is to use a connection which uses the TLS (Transport Layer Security) protocol.

I want to use TLS for my MQTT communication (see “MQTT with lwip and NXP FRDM-K64F Board“). I’m still learning MQTT, and I’m even more learning about the fundamentals of security and security protocols. So this article is about what I have learned recently, and what I can use to make my data communication secure: Network stack architecture, symmetric and asymmetric encryption and certificates.

Certificate Based Key Exchange

Certificate Based Key Exchange

Continue reading

MQTT with lwip and NXP FRDM-K64F Board

In the area of IoT (Internet of Things), one obvious need is to have a way to send and receive data with an internet protocol. MQTT (or Message Queue Telemetry Transport) is exactly like that: a light-weight Machine-to-Machine communication protocol. With the MQTT protocol a microcontroller (or ‘client’) can send data and/or subscribe to data. For example to the Adafruit.IO:

Adafruit MQTT IO Feed

Adafruit MQTT IO Feed

Continue reading