PaulRB / Wemos-Weather-Station

Outdoor Weather Station with Wind Speed, direction &Rainfall sensors
56 stars 7 forks source link

one pin communication #4

Open MrSteffenME opened 3 years ago

MrSteffenME commented 3 years ago

hi, I've been running D1s for almost 3 years but with a lack of analog pins, your project is exactly what I needed! I recreated your whole project but the only issue is I can't get any communication protocol running between d1 pro and attiny85, I need to run the one-pin comms because my attiny pins are now full. can you assist me into this, please

I don't know if it's a library issue or I don't know. it cant be the pins, it is correctly connected and flashing the attiny with an uno r3. i tried 1mhz and 8 mhz config on the attiny but nothing. i used the wire.h and that worked with sample/ testing code but yours is not config in that way and it uses 2 pins

PaulRB commented 3 years ago

Hi, are you using the code and schematic exactly as shown in this repo, or are you wanting to make some changes or adaptations?

MrSteffenME commented 3 years ago

I have similar sensors connected but that's on the d1 directly. The issue is with the attiny comms, that part is exactly the same but with the line: SoftwareSerial slaveMCU(SLAVE_RX, SLAVE_TX, false, 64); mine is just SoftwareSerial slaveMCU(SLAVE_RX, SLAVE_TX), with yours it freaks out with the last two params:

1.1Master:19:54: error: no matching function for call to 'SoftwareSerial::SoftwareSerial(int, int, bool, int)' SoftwareSerial slaveMCU(SLAVE_RX, SLAVE_TX, false, 64); ^ D:\NGA\Arduino\WeatherStation\Master\1.1Master\1.1Master.ino:19:54: note: candidates are: In file included from D:\NGA\Arduino\WeatherStation\Master\1.1Master\1.1Master.ino:10:0: C:\Users\Steffen\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SoftwareSerial\src/SoftwareSerial.h:93:5: note: SoftwareSerial::SoftwareSerial(int8_t, int8_t, bool) SoftwareSerial(int8_t rxPin, int8_t txPin = -1, bool invert = false); ^ C:\Users\Steffen\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SoftwareSerial\src/SoftwareSerial.h:93:5: note: candidate expects 3 arguments, 4 provided C:\Users\Steffen\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SoftwareSerial\src/SoftwareSerial.h:89:5: note: SoftwareSerial::SoftwareSerial() SoftwareSerial(); ^ C:\Users\Steffen\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SoftwareSerial\src/SoftwareSerial.h:89:5: note: candidate expects 0 arguments, 4 provided Multiple libraries were found for "SoftwareSerial.h" Used: C:\Users\Steffen\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\libraries\SoftwareSerial Not used: E:\Documents\Arduino\libraries\espsoftwareserial-master exit status 1 no matching function for call to 'SoftwareSerial::SoftwareSerial(int, int, bool, int)'

this is with my esp8266 library. but I cant think that is whats the issue?

PaulRB commented 3 years ago

Looks like that library has changed since I last used it. No longer accepts 4 parameters, only 3. I think that last parameter is buffer size, which seems to default to 64 in latest version, so try removing that.

MrSteffenME commented 3 years ago

I did and I used software serial with both pins in other devices, so I don't think it's that, maybe it can be. I am busy with this the last 5 days. I change the attiny to only an output, to send a byte every 1000 and the d1 to input. only testing the comms, but that is not even working. I also changed the pin from #define SERIAL_OUT 0 to #define SERIAL_OUT PB0, but still nothing. I tried to send a command to attiny switching a pin on, nothing. I tested 2 attiny with blink sketches that worked 100%. looks like a long night for me

PaulRB commented 3 years ago

Why are you using attiny85?

I used one in this project because my windspeed, direction and rain sensors are "dumb" and need continuous monitoring: counting pulses etc. If I used the Wemos to monitor the sensors directly, I could not reduce the current to below around 20mA, which would have drastically reduced the battery life. The tiny85 can monitor the sensors using only about 0.5mA. I did not use the tiny85 only to provide extra digital or analog pins, if that was my only requirement I would have used i2c chips/modules for that, which would not require an extra sketch to be uploaded to them, and would avoid the difficulties that come with getting two MCU to communicate. Getting this to work was difficult and took time and frustration, and you are discovering the same.

So what I am saying is: if what you want is extra analog or digital I/o for the Wemos, I would not recommend attiny85 for that. I would only recommend to use attiny85 if you need active monitoring of sensors while Wemos is in deep sleep.

At some time in the future, I will re-build my weather station, and I will use neither Wemos or attiny85. Instead I plan to use atmega328 and rfm95 LoRa radio module. With these I can achieve far better range and battery life.