Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Wireless Thermometer

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1136

poland.gif
PostPosted: Sat Jan 21, 2017 1:36 am    Post subject: Wireless Thermometer Reply with quote

Hello. In this project I use new method for receiving packets on this cheapest radios.
..and this method gives really good results.

I don`t try to recognize start of frame but use circular buffer and when Frame End is foud then in custom lenght buffer you have only data without preamble.
Project also contains 2cm x 2cm PCB designed in KiCAD
Battery powered transmitter measure also voltage. Everything is send with CRC.

If you have this cheapest radios then must try this code Very Happy

Code:
'****************************************************
'*             WIRELESS THERMOMETER                 *
'*             WITH CIRCULAR BUFFER                 *
'*                RECEIVER PART                     *
'*              niveasoft@tlen.pl                   *
'*                 2017-01-20                       *
'****************************************************

'-DESCRIPTION-
' Code receive incomming data in interrupt background mode.
' If special Tail byte is detected then this byte is the last in whole frame.
' Circular buffer size is calculated to hold only 14 bytes.
' So if Tail is detected then rest of buffer must be previous data.
' In this way preamble is rejected and you have only data bytes.
' These are coded im Manchester six bytes. First two contains data from DS18B20
' Second two bytes contains ADC value readed from node battery terminals.
' Fifth byte is a Node number so you can have more of them and recognize.
' Sixth byte is a CRC from provious five bytes.


Code:
'****************************************************
'*             WIRELESS THERMOMETER                 *
'*             WITH CIRCULAR BUFFER                 *
'*               TRANSMITTER PART                   *
'*              niveasoft@tlen.pl                   *
'*                 2017-01-20                       *
'****************************************************

'-DESCRIPTION-
' For energy saving device is in Powerdown Mode most of the time.
' It weakup after Watchdog Restart every ~8s
' SRAM is not cleared so even after Reset variable Count holds seconds counter
' So every ~8s x Period_const device read Raw data from DS18B20 and measure battery voltage.
' If no error has occured then it packed data, own number and calculated CRC is coded
' into Manchester and send via radio.
' Also for energy saving voltage divider is enabled only for measure time.
' Schematic and PCB design can be found at http://bart-projects.cba.pl
 


With two AA batteries (<3V) signal came thru walls. You can power tramsmitter up to 5V
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Jan 21, 2017 9:59 am    Post subject: Great job!! Reply with quote

Great job!!
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1198
Location: France

france.gif
PostPosted: Sat Jan 21, 2017 5:19 pm    Post subject: Reply with quote

nice tools !
Would you please let us know where you find the hardware : ref and retaillers ?
many thanks
JP Wink
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1136

poland.gif
PostPosted: Sat Jan 21, 2017 5:31 pm    Post subject: Reply with quote

Hello JP.
They are the cheapest chinese radios $0,5 Example Link
But locally in my country they are in the same price. The truth is I got them from someone Very Happy
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Sun Jan 22, 2017 11:18 am    Post subject: Reply with quote

Hello EDC,

Thank you for sharing this wonderful project. It is a complete project with both sender and receiver. This is a great example on how to use these cheap modules with Manchester encoding.
You used a number of techniques which make it both a good example and usable. Indeed Great work !

_________________
Mark
Back to top
View user's profile Visit poster's website
Ross_ValuSoft

Bascom Member



Joined: 20 Nov 2005
Posts: 275
Location: Melbourne, Australia

australia.gif
PostPosted: Thu Feb 02, 2017 8:59 am    Post subject: Reply with quote

Do you have an English version of your webpage?

Thanks.

Ross

_________________
Ross McKenzie
Melbourne Australia
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1136

poland.gif
PostPosted: Thu Feb 02, 2017 11:02 am    Post subject: Reply with quote

No, I dont have but this is good time to point me this Very Happy
I have lot of articles/news want to share but my old page was time consuming when I want to add something new.
So I made copy of the old page and install Wordpress on it.
New articles will come in english or maybe I find the way how to add language switch on page. Hahahah.
Sorry but this all things are time consuming too.
But the effort that I made is that I can finally have more time Very Happy

And about thermometer.
Code for Receiver only showing code needed for receiving data and is written for example.
Assumption of ADC value was that Base station on the fixed treshold lit the Led about Low battery Very Happy

..but if enyone want to view voltage then this can be done very easy.
Because internal voltage reference is 2,56 and if you move comma two places into the right you get 256.
Voltage divider is 1/2 so finally after cutting calculations this should do the job Very Happy
Code:
Dim Volt As String * 10
Voltage = Makeint(bytes(3) , Bytes(4))           'Word ADC value from sensor
          Shift Voltage , Right , 1
           Volt = Str(voltage)
            Volt = Format(volt , "0.00") + "V"


Don`t need to tell me "its cold outside" I know it Very Happy
Back to top
View user's profile Visit poster's website
Ross_ValuSoft

Bascom Member



Joined: 20 Nov 2005
Posts: 275
Location: Melbourne, Australia

australia.gif
PostPosted: Sat Feb 04, 2017 9:10 am    Post subject: Reply with quote

Thanks for your reply.

I visited your .pl website but cannot find anything on this project. In particular I wanted to see your receiver details. Do you have a direct link to that part.

Sorry for being a single language pest.

Regards,

Ross

_________________
Ross McKenzie
Melbourne Australia
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1136

poland.gif
PostPosted: Sat Feb 04, 2017 12:13 pm    Post subject: Reply with quote

Ross_ValuSoft wrote:
Do you have a direct link to that part.

No, I dont have page about descripted this receiver yet. Hahaha Very Happy

After some time in building "things" I can say that some parts of code is needed again an again.
So, I`m not the first I think, I found that this part should be done once but neatly.

I`m very happy about how this work because I know how this works before. Hahaha Very Happy

One thing I know about this receivers is that they dont like noisy power supply.
Charger 5V from Samsung phone/tablet works great but another charger for my wireles headphones is horrible noisy.
You can check quality of power source by oscilloscope or even headphones via 100nF capacitor Very Happy

This code was developed for my colegue who says that the station Hi have don`t send data if temperature is below minus Hahahaha Very Happy
So I`ve made some checks you can see on the pictures. Sending data thru window or walls is no problem Very Happy

This guy like "retro" things so 7 segment display will take the place of lcd but .... in H4 bulb Hahaha Very Happy
Once I was saw one design in Smirnoff`s bottles Very Happy

So this PCB I made yesterday for tests, but you must keep in mind that code was developed for handling more satelites, not only one.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Sat Feb 04, 2017 2:08 pm    Post subject: Reply with quote

Nice pitures! I like the idea of this modern nixie Wink
Have not seen any snow this year. Always looks beautiful to me.

_________________
Mark
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1136

poland.gif
PostPosted: Thu Feb 09, 2017 1:06 am    Post subject: Reply with quote

I like to finish what I`m starting Very Happy
This time three displays 7Segment multiplexed of this receiver. They are visible from afar.
Wireless work same as previous. Switch is added for change modes.
You can view temperature inside, outside and transmitter battery voltage.
After mode change you got info for about 1s "In", "Out" or "Bat"
Automatic brightness control is implemented. COMPARE1B time is controlled by photoresistor Wink
This base is for my colegue and displays will be separated.
Short demo video can be watched here link

Like You see winter does not surrender.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Thu Feb 09, 2017 10:23 am    Post subject: Reply with quote

Wow, what a light. That is bright indeed! Amazing the camera could capture it.
Thank you for sharing and for the video. automatic dim is a nice option Very Happy

_________________
Mark
Back to top
View user's profile Visit poster's website
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 1136

poland.gif
PostPosted: Thu Mar 09, 2017 8:20 pm    Post subject: Reply with quote

Someone ask me if transmitter code will fit into Tiny13 and this is the answear Very Happy
I must do some optimisations and everything work fine.
This is nice that we can work on variables created by function like that:
Code:
'-[MANCHESTER]-  '1 become "01" and 0 become "10" so longest break in TX is "1001"
Function Code(byref Temp As Byte) As Word                   'we use target variable instead local

   Multip = 8
   Do
      Shift Code , Left , 2
      Decr Multip
      If Temp.multip = 1 Then
         Code = Code + 1                                    '01
      Else
         Code = Code + 2                                    '10
      End If
   Loop Until Multip = 0

End Function


NOTE Attiny13 internal voltage reference is 1,1V so for 3,3V supply resistor R2 should have 20K and for 5V >35,5K
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum