-
Notifications
You must be signed in to change notification settings - Fork 11
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CC1101 to ATMEGA328P pinning #11
Comments
There is no definite answer to your question :-) Firstly - have you looked at the README for the firmware? OK assuming you're doing this.... The reason there is no definite answer is that evofw3 can be made to run on a number of avr platforms connected to a cc1101. The options in the evofw3_avr board options select one of the combinations I've seen or have had reported. The following options are currently supported Note the code DOES NOT use Arduino pin numbers - these are the avr pin identifiers and these are the values specified in xxx_pins.h atmega328p atmega32u4 If you've got an off the shelf package then one of these will probably work. Note: |
Hello Ghoti57
Thanks for the detailed reply. It is much appreciated. I've no issues using
ATM328 pin names, but what I couldn't understand was the "#if( GDO0==INT0
)" type statements in atm328_pins.h, as I could not find where GDO0 and
GDO2 were defined. I am using a standard UNO connecting the CC1101 via
5/3.3v level translators, so does this count as 'pro' pinning? (
GDO0-INT0(D2) GDO2-INT1(D3))
Cheers
Glenn
…On Thu, 18 Mar 2021 at 11:41, ghoti57 ***@***.***> wrote:
There is no definite answer to your question :-)
Firstly - have you looked at the README for the firmware?
Are you using the custom evofw3_avr board definitions?
You cannot build evofw3 with the standard Arduino board definitions.
OK assuming you're doing this....
The reason there is no definite answer is that evofw3 can be made to run
on a number of avr platforms connected to a cc1101.
The problem is that many of the off-the-shelf packages make the
connections in different ways.
The options in the evofw3_avr board options select one of the combinations
I've seen or have had reported.
The options are actually controlled from evofw3_avr:boards.txt
<https://github.com/ghoti57/evofw3_avr/blob/master/boards.txt>
This file specifies the values for GDO0, GDO2 and CCSEL which control
xxx_pins.h
The following options are currently supported
Note the code DOES NOT use Arduino pin numbers - these are the avr pin
identifiers and these are the values specified in xxx_pins.h
atmega328p
MOSI-B3 MISO-B4 SCK-B5 CSN-B2
nano: GDO0-INT1(D3) GDO2-INT0(D2)
pro: GDO0-INT0(D2) GDO2-INT1(D3)
atmega32u4
MOSI-B2 MISO-B3 SCK-B1
GDO0-TXD1(D3) GDO2-RXD1(D2)
ProMicro: CSN-B6
SHA: CSN-B0
If you've got an off the shelf package then one of these will probably
work.
If you're making your own from components then, depending which processor
you have, I'd go for the either atmega328p:nano or atmega32u4:ProMicro as
they're the most common options.
Note:
atmega328p systems MUST have a 16MHz clock - it won't run on 8MHz.
atmega32u4 systems will run on an 8Mhz system
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE2OSAFDGVFLF6XUXRJ6ETTEHRH5ANCNFSM4ZMKZESQ>
.
|
Does this count as "pro" pinning? Since you're in control connect GDO0 to D3 and GDO2 to D2 and the SPI port as specified- then it'll be 'nano' pinout atmega328p |
Have you got this working now? |
Hello Ghoti57
I have indeed - Brilliant - but I had to makes a change in the code to get
it to compile as I got this error when target was ATmega328P
config.h:22:2: error: #error No Host baud rate defined
#error No Host baud rate defined
....unless I added a baud rate, in, so I popped in the #define addition in
config.h below, then it works just lovely:
#elif defined ARDUINO_EVOFW3_ATMEGA328P
#include "atm328_pins.h"
define HOST_RATE 57600 // try this as I get an error without it
#else
#error "CC1101 connection not defined for target - use evofw3_avr board
definitions"
#endif
I am hoping to get this to output 'decoded information' giving me the valve
position for each TRV - so this is a fantastic start.
Cheers
Glenn Wardle
…On Sun, 21 Mar 2021, 11:15 ghoti57, ***@***.***> wrote:
Have you got this working now?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE2OSHLDWYALEXKFZL4I53TEXILXANCNFSM4ZMKZESQ>
.
|
That's because you're not using the custom board definitions. Install the evofw3_avr custom board definitions and use them. DO NOT use the Arduino board definitions - that way will cause pain and confusion when something doesn't work |
Hello ghoti57 - right, I have a fully working system!
Please - any chance you could give me some advice on a modification I
would like to try?
I would like to pull out a few of the messages as standard integers,
but I don't understand enough C string manipuation and pointers to
extract what I'm looking for.
The specific fields I would like as integers are: the RSSI, the
transmitting device type, the device id, and the payload when the
packet ID is 3150 (heat demand).
Your code is a wondeful bit of work - but well outside of my current
knowledge limit.
Cheers
Glenn Wardle
…On Mon, 22 Mar 2021 at 08:11, ghoti57 ***@***.***> wrote:
That's because you're not using the custom board definitions.
Checkout the README on evofw3.
Install the evofw3_avr custom board definitions and use them.
There's no need to edit any code.
DO NOT use the Arduino board definitions - that way will cause pain and confusion when something doesn't work
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Hi Glenn,
I'm not sure what you're trying to do.
All the information you refer to is in the current output.
Adding any additional output from evofw3 is EXTREMELY difficult because of the time sensitive nature of its function.
Any analysis of the messages is much better done on the attached host system.
Are you aware of https://github.com/zxdavb/evohome_rf
…On 29 Mar 2021, 10:49, at 10:49, GlennWardle ***@***.***> wrote:
Hello ghoti57 - right, I have a fully working system!
Please - any chance you could give me some advice on a modification I
would like to try?
I would like to pull out a few of the messages as standard integers,
but I don't understand enough C string manipuation and pointers to
extract what I'm looking for.
The specific fields I would like as integers are: the RSSI, the
transmitting device type, the device id, and the payload when the
packet ID is 3150 (heat demand).
Your code is a wondeful bit of work - but well outside of my current
knowledge limit.
Cheers
Glenn Wardle
On Mon, 22 Mar 2021 at 08:11, ghoti57 ***@***.***> wrote:
>
> That's because you're not using the custom board definitions.
> Checkout the README on evofw3.
>
> Install the evofw3_avr custom board definitions and use them.
> There's no need to edit any code.
>
> DO NOT use the Arduino board definitions - that way will cause pain
and confusion when something doesn't work
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub, or unsubscribe.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#11 (comment)
|
Hello ghoti57
It was the zxdaveb pages that led me down this path...
There is (IMHO) an inherent shortcoming in the Evohome system that I would
like to fix, and your code makes this possible...
When an EVOhome TRV closes its valve, the command to the controller saying
no more heat is required only gets sent after the valve is fully closed. My
system has TRVs on every radiator, which means when the final TRV switches
off, the pump is effectively blocked before demand ends. This is not ideal,
and means the boiler overrun has ‘nowhere to go’. My boiler runs the pump
for 3 minutes after demand ends to make best possible use of all the
residual heat, but the Evohome TRV sequence completely undermines this. I
complained to Resideo, but they were simply not interested, so I want to
‘fix it’ another way. I have built up a map of all my TRV IDs – I want to
look at the heat demand:
https://github.com/zxdavb/The-Evohome-Protocol/wiki/3150:-Zone-Heat-Demand
of all TRVs. If the demand is falling, and it falls below a set threshold
then I can simply (in hardware) disable boiler demand. This will allow the
radiators to fully utilise all the boiler’s residual heat before the final
valve closes.
I appreciate your code is very tight for timing, but my plan was to remove
all the output monitoring and serial feed stuff. All I need is a single
GPIO which will go high when the overall heat demand is ‘almost’ zero. Yes
I could use another MCU, and decode out the serial stream, but I wanted to
do all one device if I could.
Cheers
Glenn
…On Mon, 29 Mar 2021 at 12:30, ghoti57 ***@***.***> wrote:
Hi Glenn,
I'm not sure what you're trying to do.
All the information you refer to is in the current output.
Adding any additional output from evofw3 is EXTREMELY difficult because of
the time sensitive nature of its function.
Any analysis of the messages is much better done on the attached host
system.
Are you aware of https://github.com/zxdavb/evohome_rf
On 29 Mar 2021, 10:49, at 10:49, GlennWardle ***@***.***> wrote:
>Hello ghoti57 - right, I have a fully working system!
>Please - any chance you could give me some advice on a modification I
>would like to try?
>I would like to pull out a few of the messages as standard integers,
>but I don't understand enough C string manipuation and pointers to
>extract what I'm looking for.
>The specific fields I would like as integers are: the RSSI, the
>transmitting device type, the device id, and the payload when the
>packet ID is 3150 (heat demand).
>Your code is a wondeful bit of work - but well outside of my current
>knowledge limit.
>Cheers
>Glenn Wardle
>
>On Mon, 22 Mar 2021 at 08:11, ghoti57 ***@***.***> wrote:
>>
>> That's because you're not using the custom board definitions.
>> Checkout the README on evofw3.
>>
>> Install the evofw3_avr custom board definitions and use them.
>> There's no need to edit any code.
>>
>> DO NOT use the Arduino board definitions - that way will cause pain
>and confusion when something doesn't work
>>
>> —
>> You are receiving this because you authored the thread.
>> Reply to this email directly, view it on GitHub, or unsubscribe.
>
>
>--
>You are receiving this because you commented.
>Reply to this email directly or view it on GitHub:
>#11 (comment)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE2OSGEMGTNKCLQOK6ZBCDTGBQG5ANCNFSM4ZMKZESQ>
.
|
Ok, all the information you want is available in message.c. I suggest you add a function in this file e.g. The easiest place to call this so it happens once per message is in gateway.c
Pay attention to the bits that are set in rxFields for which addresses are valid. (see msg_rx_process for an example) If you want to send a message because you've identified a trigger condition call |
actually a better place to call your code would be
Now you must test However now you can get evofw3 to append text to the message when it prints it so you can debug your logic. Now when you recognise trigger conditions in you code you can set |
Hello ghoti57
Thanks for the advice. It is appreciated. I will give that a try as
soon as I get a bit of time.
Glenn
…On Mon, 29 Mar 2021 at 16:14, ghoti57 ***@***.***> wrote:
Ok,
all the information you want is available in message.c.
I suggest you add a function in this file e.g.
uint8_t msg_glenn( struct message *msg)
Which can analyse each message.
The easiest place to call this so it happens once per message is in gateway.c
if( !nRx ) {
msg_glenn( rx );
msg_free( &rx );
}
Pay attention to the bits that are set in rxFields for which addresses are valid. (see msg_rx_process for an example)
and also (in case a bad message gets through) that msg->error==MSG_OK
If you want to send a message because you've identified a trigger condition call msg = msg_alloc(), populate the message and then call msg_tx_ready(&tx) (or whatever you want to do)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Actually just realised that your function does not usefully return anything so it looks like |
I will start off with your code 'as is' and use two Arduinos - the second
one will decode the serial stream and pull out the stuff to control the
boiler. I will get that all working first, then see if I can get it into a
single MCU.
…On Mon, 29 Mar 2021 at 16:31, ghoti57 ***@***.***> wrote:
Actually just realised that your function does not usefully return
anything so it looks like
void msg_glenn( struct message *msg )
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE2OSDXUSPI4FLXFL6UWM3TGCTNVANCNFSM4ZMKZESQ>
.
|
There should be no problem doing the analysis in a single MCU within the existing evofw3 code. Just remembered - to get the custom text appended to the messages you'll have to set |
Forget trying to decode the serial stream. |
Something like this will get you going
|
Hello gohti57 |
Which CC1101 modules are you using? There have been a number of issues recently with the square green ones - they appear to be made by a number of different manufacturers and the quality is variable. In particular the 26MHz crystals being used don't seem to be very accurate. Have you tried the evofw autotune procedure. Preferably from the Arduino GUI serial monitor, rather than any other serial program try this. (make sure line ending is set to NL & CR) Send the following command (including !) This will try to find the optimum frequency parameters for your cc1101. This will run for about 40 minutes It will report the current frequency parameter and, if it's still searching, will report "Tuning" Assuming it works save the frequency with |
Which processor are you using? The atmega328p modules (nano etc) are forced to implement a SW UART mechanism for RX and it's not as good as using a HW UART which is possible on ATMega32U4 modules (Pro Micro, Leonardo etc) . I'm selling these modules SSM These red cc1101 modules all seem to come from one manufacturer. search for cc1101 E07 |
Hello Ghoti57
You were spot on. My board is the green square one, widely available on
eBay, which is one of the few specifically tuned to 868. Once I did the
tuning you suggested, the number of messages increased enormously, and I
can see all radiators. Is this tuning option and its effect in a read me
file somewhere?. I have ordered a 'red' cc1101 board as suggested so I will
see how that compares. All these tests have been on the micro with h/w
UART. I am going to try running uno and micro at the same time and capture
both logs in one file to see if they see exactly the same messages.
Cheers
Glenn
…On Tue, 20 Apr 2021, 18:58 ghoti57, ***@***.***> wrote:
Which CC1101 modules are you using?
There have been a number of issues recently with the square green ones -
they appear to be made by a number of different manufacturers and the
quality is variable. In particular the 26MHz crystals being used don't seem
to be very accurate.
Have you tried the evofw autotune procedure.
Preferably from the Arduino GUI serial monitor, rather than any other
serial program try this. (make sure line ending is set to NL & CR)
Send the following command (including !)
!FT
This will try to find the optimum frequency parameters for your cc1101.
You will see good AND bad received messages reported and lines that look
like
!C D 21 65 5A
This will run for about 40 minutes
You can check whether it's complete at any time by sending
!F
It will report the current frequency parameter and, if it's still
searching, will report "Tuning"
Assuming it works save the frequency with
!FS
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE2OSDCI27MBXNK55RE423TJW6DDANCNFSM4ZMKZESQ>
.
|
Sorry currently no readme on tuning. It's one of the topics I want to add to the wiki. |
Hello ghoti57 |
here's the message structure in message.c uint8_t fields; // Fields specified in header uint8_t addr[3][3]; uint8_t opcode[2]; uint8_t csum; uint8_t nPayload; uint8_t nBytes; Look at If you really want a single value for the complete address you'll need something similar to One comment is I'd call your code for EVERY received message and put the tests to decide if you're interested in it in the function. This means |
Hello ghoti57 |
Hi Glenn, you need something like this (call msg_rx_hook() from gateway.c Some of the code is to make it easier for you to reuse with say different address fields or different opcodes
|
Hello ghoti57
Real progress, but a different approach to what you suggested. Rather than
attempting to work in decimal for the IDs, it was much easier to work in
hex, so I used addr1 (one byte) as the feed into a switch statement (just 5
choices), then cascaed a second switch statement off each case (3 or 4
choices) and fed this with addr2 (in message.c). I've also changed the
msg_print_field state machine so it only runs if it sees a 3150 message.
Any other messages just send it to msg->state = S_COMPLETE. All works
lovely. I've now mapped the valve position against 3150 messages and have a
clear understanding of the TRV demand threshold needed to cut-off the
boiler at 'the right time'. Given all I need is a GPIO pin or two to
control the boiler (overriding the BDR91), is there an easy way to get the
code to run (on the Arduino Micro - ATmega32u4) without having a host USB
device connected? - Ideally, it would be good if this aspect itself could
be selectable so I always have an option to monitor (for future debug)
Cheers, Glenn
…On Tue, 27 Apr 2021 at 13:03, ghoti57 ***@***.***> wrote:
Hi Glenn,
you need something like this (call msg_rx_hook() from gateway.c
Some of the code is to make it easier for you to reuse with say different
address fields or different opcodes
struct my_trv_data {
uint32_t id;
// Any other data fields you need for whatever you want to keep track of for each TRV
}
static struct my_trv_data myTRVs[] = {
// List the IDs of your TRVs here (don't put leading zeroes in)
{ .id = 12345 },
{ .id = 12346 },
{ .id = 213456 },
// etc.
// Must be last
{ .id=0xFFFFFFFF }
};
static struct my_trv_data * find_trv( uint32_t id ) {
struct my_trv_data *trv;
for( trv=myTRVs ; trv->id!=0xFFFFFFFF; trv++ ){
if( id==trv->id )
break;
}
if( trv->id==0xFFFFFFFF )
trv = NULL; // Not a message from one of listed TRVs
return trv;
}
#define CLASS_GWAY 18
#define CLASS_CTLR 1
#define CLASS_TRV 4
void msg_rx_3150( struct message *msg ) {
uint8_t class;
uint32_t id;
// extract the first address (class:id) from the message
msg_get_addr( msg->addr[0], &class, &id );
if( class==CLASS_TRV ) {
struct my_trv_data *trv = find_trv( id );
if( trv != NULL ) {
// do something with the current TRV
// do something to do with the system
}
}
void msg_rx_hook( struct message *msg ) {
uint16_t opcode = ( msg->opcode[0]<<8 ) | msg->opcode[1];
switch( opcode ) {
case 0x3150: msg_rx_3150( msg ); break;
// Handle any other opcodes here
}
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE2OSEEUZUC76LQQB4IDB3TK2RX5ANCNFSM4ZMKZESQ>
.
|
Glad you're making progress. However, I don't believe you should have been modifying the msg_print functions. Doing this precludes all possibility is just 'switching on' print for debug purposes at some time in the future. All your references to decimal and hex suggest to me you don't understand what the existing code does and how to use the content of the message structure. Hex and decimal are irrelevant. All your logic should be based on the BINARY values returned by msg_get_addr. I suspect you're making it more difficult than necessary. Look at my suggested code again |
Hello ghoti57
I have to find a way to use this without any USB connection. It has to be
standalone, but the micro version does not do anything until it connects to
a USB master device with an open comm port. I have no issues with stuffing
in compiler directives to 'rem out' all the sprintf_P... functions if
that's what's needed.
Cheers
Glenn
…On Thu, 6 May 2021 at 19:10, ghoti57 ***@***.***> wrote:
Glad you're making progress.
However, I don't believe you should have been modifying the msg_print
functions. Doing this precludes all possibility is just 'switching on'
print for debug purposes at some time in the future.
All your references to decimal and hex suggest to me you don't understand
what the existing code does and how to use the content of the message
structure. Hex and decimal are irrelevant. All your logic should be based
on the BINARY values returned by msg_get_addr.
I suspect you're making it more difficult than necessary.
Look at my suggested code again
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATE2OSEDHDGC5L2ZVQJZM2TTMLLQZANCNFSM4ZMKZESQ>
.
|
Decoupling from the serial port is high on my to-do list for the next release |
Hi, is there a way to check whether the CC1101 is working or correctly connected? (I am using a VM with attached Pro Micro and CC1101 Connections: CC 1101 Pro Micro The Pro Micro is identified in Ubuntu as "/dev/ttyACM0 - SparkFun_evofw3_atmega32u4" so that's good. |
I have put together two CC1101/SS Micro HGI80 emulators recently, one red and one green. I have connected my pins differently from those you are using - I see you're using the ones suggested by ghoti57. My connections differ for GDO0 and GDO2 only; this is what I am successfully using: - Green CC1101 SS Micro Red CC1101 SS Micro The CC1101 pins above are in the order top-to-bottom with the boards chip-side-up and the pins to the left. Edited slightly: If you are using a different ATMEGA32U4 board from me then I would suggest you just make sure you connect GDO0 to your board's Tx pin and GDO2 to its Rx pin - but that seems to be what you have done, so ... |
Well, I 've checked the CC1101 and on another board it's receiving packages so seems ok. |
If you are using the custom board definitions for the pro micro, as per the instructions, then I guess incorrect connections is still a possibility. Pin naming can confusing; can you confirm that you are connecting GDO0 to D1 (aka Tx aka PD3) not D3 as you posted, and also that you have GDO2 connected to D0 (aka Rx aka PD2) not D2 as you posted? On the boards I have seen, the silk screen printing clearly indicates the Rx and Tx pins; make sure you are using those, not the pins marked "2" and "3" which are D2 (aka SDA aka PD1) and D3 (aka SCL aka PD0). Nothing needs to be connected to those two. I have no idea what your level of experience is so please forgive if I'm telling you things which are already obvious. |
Not sure if the following was really the culprit at my side but I experienced the same issue as ierlandfan. After disconnecting the CC1101, sending a !ER command to reset the EEPROM, connecting the CC1101 again it worked. |
Using this image as a reference CC1101 Pro Micro |
Ways you can check the cc1101 configuration is If it prints anything else enter plug the USB back in and try Any error here suggests the SPI connections are wrong. Also failure to report the evofw3 version string on initial connection is also a suggestion that the SPI connection is having problems There can also be minor problems with the USB interface of the atmega32u4. You can get it to restart by changing the baudrate from the computer TWICE. |
If it prints anything else enter That did the trick! |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Can you please tell me the pinning between ATMEGA328P (standard UNO) and the CC1101. I don't fully understand atm328_pins.h which I presume sets this. Thanks
The text was updated successfully, but these errors were encountered: