RasPi-mqtt-c
This C sample shows how to use MQTT to communicate with AirVantage.
This source code is based on http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.embedded-c.git/ sample.
Scenario
This version simulates and sends humidity values and send temperature value (static value) as well.
Configuration
Setup your favorite distribution on your Raspberry Pi (see http://www.raspberrypi.org/help/quick-start-guide/) Edit src/stdoutsub.c:
- deviceId global variable, line 40
- server name in the main function, line 225
- username (same than deviceId) and password, in the main function, line 220 - 221
Build
Just use the Makefile: make
to build greenhouse executable.
Run
This sample can be run with ethernet bearer or AirPi Wireless connection.
AirPi shield
AirPi shield allows radio connection to internet.
Code configuration
- In a terminal: cat /proc/cpuinfo | grep Serial
- Edit src/stdout.c file and update the deviceId/serialnumber (two lines) with your raspberry Pi serial number
- make
Harware installation
- Plug your shield on Raspberry Pi and plug the USB cable from the device and your shield.
- Use shield power to have power for raspberry pi and the shield.
- Plug the antenna.
- Insert your simcard.
Process:
- Install ppp, wvdial and usb-modeswitch packages
- reboot
- In a terminal: lsusb to check the Sierra Wireless modem appears
- Copy the wvdial.conf config file on /etc
- Edit the wvdial.conf to define your APN, username and password if needed.
- Run wvdial with this configuration:
wvdial wvdial.conf network
- Check the IP using ifconfig (a ppp connection must be on)
- Start your application