The MQTT protocol is a lightweight solution for small ioT devices. Using a Mosquito (Java) server you can retrive real-time data from multiple devices for Big Data analysis.
Server: mosquitto (Java)
You can install the mosquitto
binary from your distro’s repo. It will also install Java Runtime Environment as a dependency.
Ubuntu:
sudo apt install mosquitto
Arch:
sudo pacman -S mosquitto
[Code] Client.py
#!/usr/bin/python3
import paho.mqtt.client as mqtt
from random import randrange, uniform
import time
#mqttBroker ="mqtt.eclipseprojects.io"
client = mqtt.Client("LOCAL-MSSG")
#client.connect(mqttBroker)
client.connect("127.0.0.1",1883,60)
while True:
randNumber = uniform(20.0, 21.0)
client.publish("This is a test message for agalvez.es", randNumber)
print("Just published " + str(randNumber) + " to topic LOCAL-MSSG")
time.sleep(1)