Страница 2 из 72
Re: Модуль MySensor
Добавлено: Вс июл 26, 2015 12:12 am
Ivan
По tcp модуль закончен. Осталось разобраться с реконектом. У меня не получается решить эту проблему самому, жду понедельника чтобы посоветоваться гуру.
Сделать другой интерфейс можно перегрузив 4 функции. Уже сделал, в понедельник буду проверять код.
Останется только перевести модуль на 2 языка. И можно переводить его в релиз
Re: Модуль MySensor
Добавлено: Пн июл 27, 2015 12:55 pm
cabat
При настройке в модуле адреса шлюза всегда выводится адрес "10.9.0.253" (видимо дефолтный) - это нормально?
Как узнать, какой адрес сейчас настроен? Все работает, но по началу как то путает..
Re: Модуль MySensor
Добавлено: Пн июл 27, 2015 1:21 pm
AirKing
Это ошибка в модуле/
файл mysensor.clacc.php
не помню какая строка но там
MS_HOSTHOST а должно быть MS_HOST
Ivan поправь в исходниках.
Re: Модуль MySensor
Добавлено: Пн июл 27, 2015 1:29 pm
Ivan
Исправил
Re: Модуль MySensor
Добавлено: Вт авг 04, 2015 10:47 pm
Eraser
Не отключается параметр AutoID
В Presentation хотелось бы видеть описание сенсоров, которые передает датчик
Re: Модуль MySensor
Добавлено: Ср авг 05, 2015 3:57 pm
Ivan
AutoID - исправил
Presentation info - уже сделал не выкладывал пока
Совместимо с 1.5
Проблемы в библиотеке MySensor
- В первой версии Mysensors 1.5 EthernetGate была ошибка, не было обмена. Обновляйте с github
- Замечен глюк с ack при отправки информации от node гейту - ведём переговоры
Re: Модуль MySensor
Добавлено: Ср авг 05, 2015 4:44 pm
Eraser
Может кому-то будет интересно
Я использую SerialGate, на сервере запущен скрипт, реализующий прокси между TCP и Serial
Позволяет подключатся и модулем Mysensor и MYSController
Re: Модуль MySensor
Добавлено: Чт авг 06, 2015 9:13 am
Anton_kulibin
Может кто подскажет, для версии Mysensors 1.4, была сделана нода на базе Mega 2560. в версии 1,5 скетч (доработанный под версию 1,5) уже не компилируется выкидывает ошибку, если в IDE плату переключить на UNO то все проходит на ура.
Re: Модуль MySensor
Добавлено: Чт авг 06, 2015 10:11 am
Ivan
Какую ошибку пишет. у меня только Nano, Pro mini, MS-MD, iBoard все компилятся и загружаются без проблем
Re: Модуль MySensor
Добавлено: Чт авг 06, 2015 10:30 am
Anton_kulibin
Код: Выделить всё
In file included from C:\Program Files\Arduino\libraries\MySensors/MyTransportRFM69.h:26:0,
from relay_sens__button_v1_4.ino:9:
C:\Program Files\Arduino\libraries\MySensors/utility/RFM69.h:78:62: error: 'RF69_IRQ_PIN' was not declared in this scope
RFM69(byte slaveSelectPin=RF69_SPI_CS, byte interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, byte interruptNum=RF69_IRQ_NUM) {
^
C:\Program Files\Arduino\libraries\MySensors/utility/RFM69.h:78:116: error: 'RF69_IRQ_NUM' was not declared in this scope
RFM69(byte slaveSelectPin=RF69_SPI_CS, byte interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, byte interruptNum=RF69_IRQ_NUM) {
^
In file included from relay_sens__button_v1_4.ino:9:0:
C:\Program Files\Arduino\libraries\MySensors/MyTransportRFM69.h:33:145: error: 'RF69_IRQ_PIN' was not declared in this scope
MyTransportRFM69(uint8_t freqBand=RFM69_FREQUENCY, uint8_t networkId=RFM69_NETWORKID, uint8_t slaveSelectPin=RF69_SPI_CS, uint8_t interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, uint8_t interruptNum=RF69_IRQ_NUM);
^
C:\Program Files\Arduino\libraries\MySensors/MyTransportRFM69.h:33:202: error: 'RF69_IRQ_NUM' was not declared in this scope
MyTransportRFM69(uint8_t freqBand=RFM69_FREQUENCY, uint8_t networkId=RFM69_NETWORKID, uint8_t slaveSelectPin=RF69_SPI_CS, uint8_t interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, uint8_t interruptNum=RF69_IRQ_NUM);
^
Ошибка компиляции.
Сам на работе в данный момент, дома на Ubuntu стоит IDE 1.6.5, данный скетч компилировался и загружался на UNO.
Код: Выделить всё
/**
Sensor version 1.4:
Relays 4
Ds18B20
Buttons
*/
#include <MySigningNone.h>
#include <MyTransportNRF24.h>
#include <MyTransportRFM69.h>
#include <MyHwATMega328.h>
#include <MySensor.h>
#include <SPI.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <SimpleTimer.h>
#include <Bounce2.h>
#define SN "4Relay_4Button_Temp_Dallas"
#define SV "1.4"
#define NODE_ID 17
#define CHILD_ID_TEMP 0 // Id of the sensor child
#define CHILD_ID_RELAY 1
#define RELAY_1 7 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 1 // Total number of attached relays
#define RELAY_ON 1 // GPIO value to write to turn on attached relay
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
#define BUTTON_PIN 8 // Arduino Digital I/O pin number for first button (second on pin+1 etc)
#define NUMBER_OF_BUTTONS 1 // Total number of attached buttons
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 16
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors=0;
boolean receivedConfig = false;
boolean metric = true;
Bounce debouncer1 = Bounce();
/*Bounce debouncer2 = Bounce();
Bounce debouncer3 = Bounce();
Bounce debouncer4 = Bounce();*/
int oldValue1=0;
//int oldValue2=0;
//int oldValue3=0;
//int oldValue4=0;
bool state;
MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
MyHwATMega328 hw;
MySensor gw(radio, hw);
SimpleTimer timer;
boolean lastTrip;
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgRelay1(CHILD_ID_RELAY,V_LIGHT);
//MyMessage msgRelay2(CHILD_ID_RELAY+1,V_LIGHT);
//MyMessage msgRelay3(CHILD_ID_RELAY+2,V_LIGHT);
//MyMessage msgRelay4(CHILD_ID_RELAY+3,V_LIGHT);
void setup()
{
// Startup OneWire
sensors.begin();
// The third argument enables repeater mode.
gw.begin(incomingMessage, NODE_ID, true);
// Send the Sketch Version Information to the Gateway
gw.sendSketchInfo(SN, SV);
// Fetch Button status
for (int sensor=CHILD_ID_RELAY, pin=BUTTON_PIN; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Register all relay to gw (they will be created as child devices)
gw.present(sensor, S_LIGHT);
// Then set relay pins in output mode
pinMode(pin, INPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, HIGH);
}
//After setting up the button, setup debouncer
debouncer1.attach(BUTTON_PIN);
debouncer1.interval(5);
/* //After setting up the button, setup debouncer
debouncer2.attach(BUTTON_PIN+1);
debouncer2.interval(5);
//After setting up the button, setup debouncer
debouncer3.attach(BUTTON_PIN+2);
debouncer3.interval(5);
//After setting up the button, setup debouncer
debouncer4.attach(BUTTON_PIN+3);
debouncer4.interval(5);
*/
// Initialize temperature message
unsigned long SEND_FREQUENCY = 300; // Minimum time between send (in seconds). We don't want to spam the gateway.
long previousMillis = 0;
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
// Present all sensors to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
gw.present(i, S_TEMP);
}
// Fetch relay status
for (int sensor=CHILD_ID_RELAY, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Register all relay to gw (they will be created as child devices)
gw.present(sensor, S_LIGHT);
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
}
timer.setInterval(30000, getTemp);
}
void loop()
{
// unsigned long currentMillis = millis();
// By calling process() you route messages in the background
gw.process();
timer.run();
// debouncer1
debouncer1.update();
// Get the update value
int value1 = debouncer1.read();
if (value1 != oldValue1 && value1==0) {
state = gw.loadState(CHILD_ID_RELAY);
gw.send(msgRelay1.set(state ? 0 : 1), true); // Send new state and request ack back
}
oldValue1 = value1;
/*
// debouncer2
debouncer2.update();
// Get the update value
int value2 = debouncer2.read();
if (value2 != oldValue2 && value2==0) {
state = gw.loadState(CHILD_ID_RELAY+1);
gw.send(msgRelay2.set(state ? 0 : 1), true); // Send new state and request ack back
}
oldValue2 = value2;
// debouncer3
debouncer3.update();
// Get the update value
int value3 = debouncer3.read();
if (value3 != oldValue3 && value3==0) {
state = gw.loadState(CHILD_ID_RELAY+2);
gw.send(msgRelay3.set(state ? 0 : 1), true); // Send new state and request ack back
}
oldValue3 = value3;
// debouncer4
debouncer4.update();
// Get the update value
int value4 = debouncer4.read();
if (value4 != oldValue4 && value4==0) {
state = gw.loadState(CHILD_ID_RELAY+3);
gw.send(msgRelay4.set(state ? 0 : 1), true); // Send new state and request ack back
}
oldValue4 = value4;*/
}
//Get Temperature from the Dallas sensor//
void getTemp(){
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
// Read temperatures and send them to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
// Fetch and round temperature to one decimal
float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed and no error
if (lastTemperature[i] != temperature && temperature != -127.00) {
// Send in the new temperature
gw.send(msgTemp.setSensor(i).set(temperature,1));
lastTemperature[i]=temperature;
}
}
}
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
gw.saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}