Open Vendelator opened 2 years ago
I'm sorry for the late reply.
Since it was written for M5Stack ATOM (Lite, Matrix), it is necessary to rewrite a part of communication.py. See the readme for details.
--- Modify communication.py ---
class Communication():
_DEFAULT_VID = 11914 # <-- this
_DEFAULT_PID = 5 # <-- this
And the micropython program main.py also needs to be rewritten.
--- Modify micropython main.py ---
_GROVE_PIN = {'ATOM': (32, 26),
'CORE2': (33, 32),
'BASIC': (22, 21),
'GRAY': (22, 21),
'FIRE': (22, 21),
'GO': (22, 21),
'Stick': (33, 32),
'Else': (16, 19)} # Rewrite (RxPin Number, TxPin Number) <-- For your PRi Pico
_DEVICE = 'Else' # Rewrite 'Else' <-- For your PRi Pico
Air conditioner signals tend to be long because they send all state variables, even if the temperature is changed.
This would be the NEC format series.
Header frame => ON: 16T, OFF: 8T (Top of the signal) Bit data Low => ON: T, OFF: T Bit data High => ON: T, OFF: 3T
T = 562[usec]
The header frame is followed by the data.
0001: 8,896 # 0002: 4,448 # HEADER 16T/8T 0003: 556 # 0004: 1,668 # T/3T = 1 0005: 556 # 0006: 1,668 # T/3T = 1 0007: 556 # 0008: 556 # T/T = 0 0009: 556 # 0010: 556 # T/T = 0 ...
Demodulated signal = 1100...
Please refer to here. In the case of air conditioners, the signal length is long, so it is derived from the strict NEC format.
I couldn't understand here. power state bit???
I hope it helps you even a little.
GUI I need to clarify.
When using GUI, i need to unplug and re-connect the Raspberry Pi Pico for each time i want to press record. Then i can record exactly ONE time. Then i need to re-connect the device. I don't have to close the GUI.
I am not able to send from GUI still, even after updating all referenced files used by main.py
Setting up the board Using GPIO 16 as RX and GPIO 19 as TX works well with your PIO Wave, They are also close to each other on the board and are labled as RX and TX pins. Maybe you can add this to your main.py so the the Raspberry Pi Pico is detected and those pins are used?
I am able to get the IR-led module to work using Pin 40 (VBUS) as power source, drawing current directly from USB. This works for up to around 1.5 meters. Pin 39 (VSYS) does not work.
Python main.py I am able to send commands to my AC-unit now, the issue seems to be that i have misinterpreted real code as jitter.
Example of signal containing Auto Mode, 16 DegC, No sleep, No timer, No fan swing, Not in standby:
(8992, 4496, 562, 1686, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 1686, 562, 1686, 562, 1686, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 1686, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 1686, 562, 1686, 562, 1686, 562, 562, 562, 1686, 562, 562, 562, 1686, 562)
So what i have to do now is to record enough signals to interpret what each section does. Your link has been very helpful for me. (This one --> http://elm-chan.org/docs/ir_format.html)
But at the moment, i am able to Turn AC on at 16 Deg Auto Mode, and 17 Deg Auto Mode with fan swinging. So this is awesome. I feel a lot closer to integrating my AC into my smart home.
The code i use:
from micropython import const
from gc import collect
import json
import utime as time
from machine import Pin
from UpyIrTx import UpyIrTx
from UpyIrRx import UpyIrRx
import commander # My signal creator
rx_pin = Pin(16, Pin.IN) # Pin16 GPIO16 WORKS
rx = UpyIrRx(rx_pin)
tx_pin = Pin(19, Pin.OUT) # Pin19 GPIO19 Works
tx = UpyIrTx(0, tx_pin) # 0ch
...
start = input()
rx.record(3000)
if rx.get_mode() == UpyIrRx.MODE_DONE_OK: # Redundant code, will be removed.
signal_list = rx.get_calibrate_list()
# ex) [430, 1290, 430, 430, 430, 860, ...]
else:
signal_list = (8992, 4496, 562, 1686, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 1686, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 562, 562, 1686, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 562, 1686, 562, 1686, 562, 1686, 562, 1686, 562, 562, 562, 1686, 562, 562, 562, 1686, 562)
print (signal_list) # redundant code
time.sleep(2)
tx.send(commander.signal_compiler("16", "off", "auto", "on"))
print("Auto 16")
time.sleep(2)
tx.send(commander.signal_compiler("17", "on", "auto", "on"))
print("Auto 17 Swing")
Thank you for your thorough answers.
In the GUI, is there a connector plugging and unplugging every time? In my environment, everything is working fine.(RPi Pico + micropython v1.18 & 1.19) I was able to record signal over and over again. I have uploaded the demo application separately for ESP32 and RP2040.
Sample Code for RP2040 : RX pin = 18, TX pin = 19 (Arbitrary by rewriting the source code)
This pin cannot be used as a power supply. The correct way is to use Vbus (5V). Or use 3V3 (3.3V).
I just wanted to update you that i have working hardware and code now. I am using your Tx library for the Pi Pico and it works very well in Node Red over Mosquitto MQTT.
I will update you later on with working circuits i have tested so that users easier can use your nice project with the Pi Pico.
Best Regards.
I have been at it for days now without success, i think i need some help.
I am using the Raspberry Pi Pico board for this project, the latest firmware.
I am using this module to send the signal: https://www.electrokit.com/uploads/productfile/41015/41015733_-_IR_Transmitter_Module.pdf (and this one to receive: https://www.electrokit.com/uploads/productfile/41015/41015734_-_IR_Receiver_Module.pdf)
The transceiver is 5V, but is supposed to work with 3V. The TX Signal is connected to GPIO 19 and RX Signal to GPIO 16.
When sending a signal through python directly, the receiver reacts to something being sent. Both List and Tuple seems to yield the same results.
When using GUI, i am able to Record, but unable to Send, and i am prompted with an error message saying it's unable to connect to the device. From what i can tell, this error is generated when signalframe.py uses
def _send(self):
uses commonication.pyif not self._communication.is_connect(): if not self._communication.connect(): messagebox.showerror('Error', "Can't connect device.") self._edit_on() return
I am using the standard pid and vid.
I have tried changing idle back and forth in the Micropython UpyIrTx.
The longest signal i have been able to acquire as of now is 211 long. Over several attempts it seems that if properly recorded, the last highest bit is on 210, but most often it barley reaches 158, which i am assuming is the power state bit, If its low, it enters power saving.
My received signals consists of 4 values. Two which happens initially, and two other through out the code. I am assuming the first part is to make the AC-unit know that it is supposed to receive a signal at all, after which the actual command is sent?