Is it possible to send specific 433mhz code using the attiny13? Thanks
Short answer yes i made a temperature transmitter with attiny13 and a 433 module to replace a wh2 weather transmitter.
So it is possible, but would depend a lot on what sort of message you what to send, encoding length and so on..you would have so simplify a lot any you might only be able to send a set message.
Could you post an example?
I cant find my original code but for fun i tried to use the rc-switch library with attiny 13 i just copied the parts i needed from the original library and with a bit of work its working alright.
This is the library:GitHub - sui77/rc-switch: Arduino lib to operate 433/315Mhz devices like power outlet sockets.
just load the receiver sketch on whatever arduino you prefer and load this code on a attiny13:
Not the prettiest thing i have done just a fast copy and paste job.. but it will give you a staring point at least. i had my attiny13 set for 4.8MHZ, and i had to calibrate the pulse length to 270 to get a REAL pulse lenght of 350-+ you might have to change it to get the right length.
I used core13 version 019
Binary sketch size: 600 bytes (of a 1 024 byte maximum)
and with a bit of work I'm sure you can get it smaller too
Best of luck man.
#define nTransmitterPin 0
#define nProtocol 1
#define nPulseLength 270 //pulse lenght calibrate untill the "real"
//lenght are around 350
#define nRepeatTransmit 5//retransmitts
int main(void){
init();
{
pinMode(nTransmitterPin,OUTPUT);
}
while(1) {
//sendTriState("00000FFF0F0F");//also works
send("000000000001010100010100");//works
delay(2000);
}
}
/**
* Sends a "0" Bit
* _
* Waveform Protocol 1: | |___
* _
* Waveform Protocol 2: | |__
*/
void send0() {
if (nProtocol == 1){
transmit(1,3);
}
else if (nProtocol == 2) {
transmit(1,2);
}
else if (nProtocol == 3) {
transmit(4,11);
}
}
/**
* Sends a "1" Bit
* ___
* Waveform Protocol 1: | |_
* __
* Waveform Protocol 2: | |_
*/
void send1() {
if (nProtocol == 1){
transmit(3,1);
}
else if (nProtocol == 2) {
transmit(2,1);
}
else if (nProtocol == 3) {
transmit(9,6);
}
}
/**
* Sends a Tri-State "0" Bit
* _ _
* Waveform: | |___| |___
*/
void sendT0() {
transmit(1,3);
transmit(1,3);
}
/**
* Sends a Tri-State "1" Bit
* ___ ___
* Waveform: | |_| |_
*/
void sendT1() {
transmit(3,1);
transmit(3,1);
}
/**
* Sends a Tri-State "F" Bit
* _ ___
* Waveform: | |___| |_
*/
void sendTF() {
transmit(1,3);
transmit(3,1);
}
/**
* Sends a "Sync" Bit
* _
* Waveform Protocol 1: | |_______________________________
* _
* Waveform Protocol 2: | |__________
*/
void sendSync() {
if (nProtocol == 1){
transmit(1,31);
}
else if (nProtocol == 2) {
transmit(1,10);
}
else if (nProtocol == 3) {
transmit(1,71);
}
}
void sendTriState(char* sCodeWord) {
for (int nRepeat=0; nRepeat<nRepeatTransmit; nRepeat++) {
int i = 0;
while (sCodeWord[i] != '\0') {
switch(sCodeWord[i]) {
case '0':
sendT0();
break;
case 'F':
sendTF();
break;
case '1':
sendT1();
break;
}
i++;
}
sendSync();
}
}
void transmit(int nHighPulses, int nLowPulses) {
digitalWrite(nTransmitterPin, HIGH);
delayMicroseconds( nPulseLength * nHighPulses);
digitalWrite(nTransmitterPin, LOW);
delayMicroseconds(nPulseLength * nLowPulses);
}
char* dec2binWzerofill(unsigned long Dec, unsigned int bitLength){
return dec2binWcharfill(Dec, bitLength, '0');
}
char* dec2binWcharfill(unsigned long Dec, unsigned int bitLength, char fill){
static char bin[64];
unsigned int i=0;
while (Dec > 0) {
bin[32+i++] = ((Dec & 1) > 0) ? '1' : fill;
Dec = Dec >> 1;
}
for (unsigned int j = 0; j< bitLength; j++) {
if (j >= bitLength - i) {
bin[j] = bin[ 31 + i - (j - (bitLength - i)) ];
}else {
bin[j] = fill;
}
}
bin[bitLength] = '\0';
return bin;
}
void send(char* sCodeWord) {
for (int nRepeat=0; nRepeat<nRepeatTransmit; nRepeat++) {
int i = 0;
while (sCodeWord[i] != '\0') {
switch(sCodeWord[i]) {
case '0':
send0();
break;
case '1':
send1();
break;
}
i++;
}
sendSync();
}
}
I will try it, thanks a
I've tried your code but it isn't working. The receiver module is connected to an arduino pro mini and it work fine since it receive the signal from a remote control. The strange thing is that if I put the transmitter close to the receiver it act like a jammer disturbing the remote control signal and make stop working the rx, so seem that the attiny is generating some type of signal but they aren't visible by the receiver
cheap 433mhz ook modues can definitely be used to send data. however not as simple as rs232 in and rs232 out which rarely works over more than a few inches. with proper modulation to minimize noise and dc offset many meters are possible. usually manchester or the like is required to balance levels. iirc there are ardunio libraries for this.
with minor mod that costs pennies and proper receiver its possible to go very long distance. up to 75 miles on a few milliwatts using tiny13 with these if this is any indication: OLRB: Open Long Range Beacon -low cost tracker - RC Groups
john1993:
cheap 433mhz ook modues can definitely be used to send data. however not as simple as rs232 in and rs232 out which rarely works over more than a few inches. with proper modulation to minimize noise and dc offset many meters are possible. usually manchester or the like is required to balance levels. iirc there are ardunio libraries for this.with minor mod that costs pennies and proper receiver its possible to go very long distance. up to 75 miles on a few milliwatts using tiny13 with these if this is any indication: OLRB: Open Long Range Beacon -low cost tracker - RC Groups
That's very interesting, but it reach this modding the tx in fm modulator. I need it using 433mhz frequency
Nobody?
I was able to send data with attiny13 by squeezing the code from RCSwitch
See github.com
I've tried the sketch, having modded before the board.txt but it isn't working. The receiver sketch is running on a arduino pro mini equipped with a cheap 433mhz receiver
Edit: solved by adding a short delay for each value sent. Thanks a lot guy