The trigger and echo pins of these sensors can be connected with a resistor so that only one wemos/Mega pin is required for both functions. You cannot use pins of the pcf chip for these sensors because accurate timing of the echo signal is required. The ultrasonic sensors are a little more difficult. You can use a pcf8575 I/o expander to provide an extra 16 pins for your pumps, motor and other devices You can attach an i²c backpack to these so that only 2 pins are needed to connect it to the Wemos. You don't say what kind of LCD, so I'll assume that's a 16x2 or 20x4 character LCD. I would suggest expanding the I/o of the Wemos rather than attempting to connect it to a Mega.ĭon't forget that the Mega is a 5V device and the Wemos is 3.3V so logic level shifting would be required if you go ahead with that. The Wi-Fi board itself is too small for my project as I need 6 HC-SR04 sensors, 6 pumps, 2 servos, DC motor and LCD. #define SERIAL_COMMUNICATION_CONTROL_PIN D0 // Transmission set pinĭigitalWrite(SERIAL_COMMUNICATION_CONTROL_PIN, RS485_RX_PIN_VALUE) // Init receiveĭigitalWrite(SERIAL_COMMUNICATION_CONTROL_PIN, RS485_TX_PIN_VALUE) // Init transmit Serial.println(RS485Serial.readString()) RS485Serial.print("Hello world!") // Send messageĭigitalWrite(SERIAL_COMMUNICATION_CONTROL_PIN, RS485_RX_PIN_VALUE) // Disable RS485 Transmit RS485Serial.begin(9600) // set the data rateĭigitalWrite(SERIAL_COMMUNICATION_CONTROL_PIN, RS485_TX_PIN_VALUE) // Now trasmit PinMode(SERIAL_COMMUNICATION_CONTROL_PIN, OUTPUT) ĭigitalWrite(SERIAL_COMMUNICATION_CONTROL_PIN, RS485_RX_PIN_VALUE) SoftwareSerial RS485Serial(RXPin, TXPin) // RX, TX #define SERIAL_COMMUNICATION_CONTROL_PIN 5 // Transmission set pin I've successfully made them communicate with serial RS485.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |