Hello everyone and I am asking for help.
I have been struggling with this for a long time.
I would love to send readings from the sensors to the narodmon.ru website
I managed to send something with Easyesp but I'm not here.
I am asking for a script that will send several readings from the sensors.
Example of Phyton codes from the site. Most descriptions are on the site. Maybe it's easier to write code in LUA or dzVents?
I'm giving up !!!
And I'm sorry for my English. Google translator helped me.
- Spoiler: show
- #!/usr/bin/env python2
# -*- coding: utf-8 -*-
# by Roman Vishnevsky aka.x0x01 @ gmail.com
import socket
# MAC адрес устройства. Заменить на свой!
DEVICE_MAC = '0123456789012'
# идентификатор устройства, для простоты добавляется 01 (02) к mac устройства
SENSOR_ID_1 = DEVICE_MAC + '01'
SENSOR_ID_2 = DEVICE_MAC + '02'
# значения датчиков, тип float/integer
sensor_value_1 = 20
sensor_value_2 = -20.25
# создание сокета
sock = socket.socket()
# обработчик исключений
try:
# подключаемся к сокету
sock.connect(('narodmon.ru', 8283))
# пишем в сокет еденичное значение датчика
sock.send("#{}\n#{}#{}\n##".format(DEVICE_MAC, SENSOR_ID_1, sensor_value_1))
# пишем в сокет множественные значение датчиков
# sock.send("#{}\n#{}#{}\n#{}#{}\n##".format(DEVICE_MAC, SENSOR_ID_1, sensor_value_1, SENSOR_ID_2, sensor_value_2))
# читаем ответ
data = sock.recv(1024)
sock.close()
print data
except socket.error, e:
print('ERROR! Exception {}'.format(e))
- narodmon.JPG (246.25 KiB) Viewed 414 times