Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. carleki
    3. Topics
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Topics created by carleki

    • carleki

      fail converting 1.5 sketch to 2.0
      Troubleshooting • • carleki  

      2
      0
      Votes
      2
      Posts
      1209
      Views

      DIYProjects

      Hi Carmelo42. Here your sketch modified. You need to define all MySensors parameters before to include the library. I add 2 variables (BATT_IN_PIN, BATT_VCC_PIN). You need to set Pins. I think, it'll run now. I don't check if the measure of the temperature is correct. // avec mesure de la batterie avec Vcc.h // ok avec pile CR2032 et docATmega328 8Mhz MYSBootloader et efuse 0x07 // pour DS18B20 SANS resistance // nécessite la lib OneWire : OneWireNoResistor-master.zip // // boards.txt : //proMYSBL.name=docATmega328 8Mhz MYSBootloader //proMYSBL.upload.tool=avrdude //proMYSBL.upload.protocol=arduino //proMYSBL.upload.maximum_size=30720 //proMYSBL.upload.maximum_data_size=2048 //proMYSBL.upload.speed=115200 //proMYSBL.bootloader.tool=avrdude //proMYSBL.bootloader.low_fuses=0xE2 //proMYSBL.bootloader.high_fuses=0xDA //proMYSBL.bootloader.extended_fuses=0x07 //proMYSBL.bootloader.unlock_bits=0x3F //proMYSBL.bootloader.lock_bits=0x0F //proMYSBL.bootloader.file=MySBootloader/MYSBootloader.hex //proMYSBL.build.mcu=atmega328p //proMYSBL.build.f_cpu=8000000L //proMYSBL.build.board=AVR_UNO //proMYSBL.build.core=arduino:arduino //proMYSBL.build.variant=arduino:standard #define MY_NODE_ID 123 #define MY_RADIO_NRF24 #include <SPI.h> #include <MySensors.h> #include <DallasTemperature.h> #include <OneWire.h> #include <Vcc.h> #define ONE_WIRE_BUS 4 // Pin where dallase sensor is connected #define ONE_WIRE_GND 5 #define ONE_WIRE_VCC 3 #define ID_BatPcnt 1 #define ID_Bat 2 #define BATT_IN_PIN 1 #define BATT_VCC_PIN 2 #define MAX_ATTACHED_DS18B20 16 // 60000 = 1 minute // 12000 = 2 minutes // 300000 = 5 minutes // 600000 = 10 minutes #define SLEEP_TIME 300000 // Sleep time between reads (in milliseconds) const float VccMin = 2.3; // Vcc mini attendu, en Volts. const float VccMax = 3; // Vcc Maximum attendu, en Volts (2 piles AA neuves) const float VccCorrection = 2.52/2.6; // calibration : Vcc mesuré au multimètre / Vcc mesuré par l'Arduino par vcc.Read_Volts() dans sketch 1/2 Vcc vcc(VccCorrection); OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); //MySensor gw; MyMessage msgBAT_PCNT(ID_BatPcnt,V_VAR1); // on utilise le type V_VAR1 pour le % de charge des piles MyMessage msgBAT(ID_Bat,V_VAR2); // on utilise le type V_VAR2 pour la tension des piles float lastTemperature[MAX_ATTACHED_DS18B20]; uint8_t numSensors = 0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0, V_TEMP); int oldvalue = 0; void before() { // Startup up the OneWire library sensors.begin(); } void setup() { // Startup OneWire #ifdef ONE_WIRE_VCC pinMode(ONE_WIRE_VCC, OUTPUT); digitalWrite(ONE_WIRE_VCC, HIGH); #endif #ifdef ONE_WIRE_GND pinMode(ONE_WIRE_GND, OUTPUT); digitalWrite(ONE_WIRE_GND, LOW); #endif analogReference(INTERNAL); pinMode(BATT_IN_PIN, INPUT); pinMode(BATT_VCC_PIN, OUTPUT); digitalWrite(BATT_VCC_PIN, LOW); } void presentation() { // Startup and initialize MySensors library. Set callback for incoming messages. // gw.begin(); //gw.begin(NULL, node_id, true); // Send the sketch version information to the gateway and Controller sendSketchInfo("TS sR batt", "2.0"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); sensors.setWaitForConversion(false);//saves a few mAs per read :-) to debug // Present all sensors to controller present(ID_BatPcnt, S_CUSTOM); // type S_CUSTOM pour le capteur "% de charge" present(ID_Bat, S_CUSTOM); // type S_CUSTOM pour le capteur "tension" for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) { present(i, S_TEMP); } } void loop() { // Process incoming messages (like config from server) //gw.process(); // mesure de Vcc float v = vcc.Read_Volts(); // calcul du % de charge batterie float p = 100 * ((v - VccMin) / (VccMax - VccMin)); // On envoie les données des capteurs et de l'état de la batterie au Gateway //gw.sendBatteryLevel(p); // Inutile... send(msgBAT_PCNT.set(p, 1)); // 1 décimale send(msgBAT.set(v, 3)); // 2 décimales // Fetch temperatures from Dallas sensors // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); sleep(750);//wait for conversion in sleep mode // 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>((getConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error send(msg.setSensor(i).set(temperature, 1)); lastTemperature[i] = temperature; //if (lastTemperature[i] != temperature && temperature != -127.00) { // Send in the new temperature //} } sleep(SLEEP_TIME);//wake on interrupt or after sleep-time } If you need more info : http://www.diyprojects.io/mysensors-v2-discover-news-migrate-old-sketchs/ (or http://www.projetsdiy.fr/mysensors-version2-decouverte-nouveautes-convertir-sketch/ in french)
    • carleki

      4 doors sensors and 4 move sensors on the same node
      My Project • • carleki  

      5
      0
      Votes
      5
      Posts
      1667
      Views

      carleki

      @gloob ok ! I will check the wires and signal output from the movement sensors
    • carleki

      1.5.4 and 2.0 on the same computer
      Development • • carleki  

      4
      0
      Votes
      4
      Posts
      1103
      Views

      boozz

      @gloob thanks for the hint. I've done this today. Renamed the Mysensor files (added an 'X' at the end of every .h and .cpp files) and dependencies insides these files and everything compiles again under 1.5.4, so next thing is to install 2.0. BR, Boozz
    • carleki

      debug battery powered node
      Troubleshooting • • carleki  

      5
      0
      Votes
      5
      Posts
      1339
      Views

      carleki

      @gloob said: Correct. thanks
    • carleki

      need help with node not sending info
      Troubleshooting • • carleki  

      8
      0
      Votes
      8
      Posts
      1856
      Views

      carleki

      I have added the C5 capacitor (on the "My Slim 2AA node"), and replaced the nrf24 from my GW with a NRF24L01+PA+LNA. It's way better So far, no problem .. I will keep you updated in the following days Anyway, thanks for your help
    • carleki

      How to auto reboot node every 24 hours ?
      Development • • carleki  

      15
      0
      Votes
      15
      Posts
      7910
      Views

      carleki

      I finally have found the problem : I had only Vcc.h in my VCC folder ... So the .cpp file was misisng !! --> noob alert
    • carleki

      distance + relay node
      Development • • carleki  

      6
      0
      Votes
      6
      Posts
      1973
      Views

      carleki

      @carmelo24 it's ok now here is my sketch : // Sketch pour commander un relai en mode impultionnel. #include <MySensor.h> #include <SPI.h> #include <NewPing.h> #define node_id 66 #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #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 CHILD_ID 1 #define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. unsigned long SLEEP_TIME = 500; // Sleep time between reads (in milliseconds) MySensor gw; NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. MyMessage msg(CHILD_ID, V_DISTANCE); boolean metric = true; long temps; void setup() { // Initialize library and add callback for incoming messages gw.begin(incomingMessage, node_id, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("RelayDistance", "1.1"); // Fetch relay status // Register all sensors to gw (they will be created as child devices) gw.present(RELAY_1, S_LIGHT); gw.present(CHILD_ID, S_DISTANCE); boolean metric = gw.getConfig().isMetric; // Then set relay pins in output mode pinMode(RELAY_1, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(RELAY_1, RELAY_OFF); temps = millis(); } void loop() { // Alway process incoming messages whenever possible gw.process(); // mesure de la distance si ça fait plus de 10 secondes qu'on ne l'a pas fait if((millis() - temps) > 10000) { int dist = metric?sonar.ping_cm():sonar.ping_in(); gw.send(msg.set(dist)); Serial.print(dist); Serial.print("toto"); temps = millis(); } } void incomingMessage(const MyMessage &message) { // action du relais (avec impulsion, pour action comme un bouton poussoir) if (message.type==V_LIGHT) { // Change relay state digitalWrite(RELAY_1, RELAY_ON); delay(100); digitalWrite(RELAY_1, RELAY_OFF); delay(100); } }
    • carleki

      mysensors relay stops working after few hours
      Troubleshooting • • carleki  

      10
      0
      Votes
      10
      Posts
      3701
      Views

      sundberg84

      @carmelo42 - I have been working alot with mysensors and relays. Im using a pro mini, powered from 240V AC through a iphone charger. My experience is that its mostly about the power. Your power to the relay can't come from the arduio, it needs to be feed directly from a good source. Ground can sometimes go through the arduino, but this I have had to try back and forth on each device. Caps! As mentioned above! Important! Also make sure your sketch works - begin with minimums. Attach a led instead of a relay and try HIGH/LOW and see that works. If it does, take the next step with attaching mysensors library and recive function. If that works try next step and attach relay.