Having fun with a solar panel, camera and Apache projects.pdf

jfclere 15 views 22 slides Oct 10, 2024
Slide 1
Slide 1 of 22
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22

About This Presentation

An Apache Mynewt running on ARM boards mesures temperature, pressure, humidity, report it to Apache ActiveMQ and using grafana to display measures,


Slide Content

Having fun with a solar
panel, camera, sensors
and Apache projects.
Jean-Frederic Clere @jfclere

Agenda
●Introduction.
●How it started...
●Playing with wifi
●Moving to BLE
●Getting started with mynewt (nRF52840, feather nRF52)
●Using Artemis
●Demo
●Q & A

Who I am
●Red Hat employee
−www.redhat.com
●Tomcat / httpd committer
−Tomcat.apache.org /httpd.apache.org
●In Neuchatel Office

How does it started
●Needs of cheap cluster demos (for TomcatCon)

N1 HAT
Server
WIFI
N2 HAT
WIFI
FireFox / Chrome
MASTER
Bare Metal Cloud demo

How does it changed
●Needs of cheap cluster demos (for TomcatCon)
●New RPI4 = update the cluster.
●What to do with the old ones? :)

What happens to the old ones…
RPI3
connected to relay board (hyperion)
connected the switch (manual comment)
connected wifi and internet (remote control)
Using GPIO
Apache HTTPD and cgi python
https://github.com/jfclere/door

What happens to the old ones…
RPI3
windsensor 9V power with USB
mcp3008 to convert the voltage
using SPI
Python script to read SPI and Wifi to the other
RPI3
https://github.com/jfclere/door/blob/master/mc
p3008.py

What happens to the old ones…
RPI3 (well I changed it to a RPIzero W)
Controlled by a server ssh
Use raspberry pi v2 camera
Use BME280 I2C temp/pressure/humidity
https://github.com/jfclere/pisolar/blob/main/b
me280.py

Solar running version

Other fun objects with wifi
RP2040 based there are many




Micropython version for each
Smaller objects arduino nano



Use arduino IDE (ino and cpp)
No CSI so no camera but 3.3V powerable and analogue inputs and
of course GPIO, I2C , SPI and UART.

Real stuff with wifi (arduino nano)

BLE/GATT/BME280
BLE: less energy than Wifi, move sensors in house.
GATT: normalisation, so can work with any central device.
Environment sensor: i2c BME280
Mynewt: because it is Apache.
nRF52840 dongle
nRF52840 DK
Adafruit feather nRF52 Pro with myNewt

nRF52840 dongle with mynewt
-USB DFU bootloader
-hw/bsp/nordic_pca10059
-newt build app (app=your app)
-objectcopy to get a .hex file
-nrfutil pkg generate --hw-version 52 --sd-req 0 .. to get the .hex into a zip package
-nrfutil dfu usb-serial -p dev_usb to flash the app in the device.
-Need flash map in target.yml to be able to use the Nordic bootloader
-Power by USB
-Small and cheap
-Also programmable with JLinkExe (SEGGER or DK with a cable)
-newt create-image app (app=your app)
-newt build dongle_boot (app=@mcuboot/boot/mynewt)

nRF52840 DK with mynewt
-Use JLinkExe and a cable
-TC2050-IDC-NL-050 to Debug Out for the dongle
-hw/bsp/nordic_pca10056 (for on the board Nrf52)
-Power by USB
-Big with many pins for prototyping (uart console)
-Not so cheap
-programmable with JLinkExe
-newt create-image app (app=your app)
-newt build dongle_boot (app=@mcuboot/boot/mynewt)

Adafruit Feather nRF52 with MyNewt
-Use JLinkExe and a cable
-Flat 0.05 10 pins cable to Debug Out for the dongle
-hw/bsp/ada_feather_nrf52
-Power by USB or Lipo (contains a charger for the Lipo)
-Small but with many pins for prototyping (uart console, i2c etc)
-Not as cheap as the dongle
-The MyNewt on board is old, I was NOT able to flash my app.

Collecting the GATT data on raspberry pi.
Use BlueZ from the raspbian OS.
C utility to read the /sys bluetooth file system (Bluez over the DBus)
Write the value in a /tmp file.

Sending to Artemis
Read the file, use Paho to send the data to Artemis.
"mqtts://jfclere.myddns.me:8001"
sprintf(topic,"topic/%s", devicename);
ssl_opts.enableServerCertAuth = false;
ssl_opts.verify = false;
// ssl_opts.trustStore = server_certificate.c_str();

In artemis/server/etc broker.xml
sudo cp /var/lib/httpd/md/domains/jfclere.myddns.me/privkey.pem privkey.pem
sudo cp /var/lib/httpd/md/domains/jfclere.myddns.me/pubcert.pem pubcert.pem
sudo chown jfclere *.pem
openssl pkcs12 -export -in pubcert.pem -inkey privkey.pem -out artemis.p12 -name artemis

<acceptor
name="mqtt_tls">tcp://0.0.0.0:8001?sslEnabled=true;keyStorePath=artemis.p12;keyStorePasswor
d=changeit;keyStoreType=PKCS12;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;
protocols=MQTT;useEpoll=true</acceptor>

Reporting and visualisation

Service waits for messages from Artemis on the server and put the information in
PostgreSQL database
#define ADDRESS "tcp://localhost:1883"
#define TOPIC "topic/#"

Grafana for visualisation just read the database.

Grafana screen

Little more demo on newt

Why newtmgr is so cool (using mynewt-nimble)
newtmgr image upload
newtmgr image list
newtmgr image test
power off/on or newtmgr reset
newtmgr image confirm

Try it yourself
Everything at:
https://github.com/jfclere/bt
Thanks to:
Szymon Janc, Jerzy Kasenberg and many more for the Mynewt slack channel
Ask me:
[email protected]
QUESTIONS
THANK YOU!