Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:21 02 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Can I do this?

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 09:26am 04 Apr 2016
Copy link to clipboard 
Print this post

IF I wanted to have several micromites throughout the house with temp sensors attached and each one connected to their own HC-12 433Mhz serial tdx/rcd and monitor the temperatures on one micromite with its own HC-12 module

I know I can set each remote micromite so it sends the temperature at set intervals
However I want to be able to monitor/recieve the information on a micromite with just ONE hc-12 txd/rxd

Can I do it? and if so HOW?

I know all the hc-12's will have to be on the same frequency and I know they will all work together, but how do I stop them all trying to talk at the same time?

If they did this then the micromite used as the reciever would just get garbage basically as the transmitters would interfere with each other and block each others transmission?

Is there a way to stop this happening?
Ideally I'd like each remote transmitter to transmit one at a time with none of them transmitting at the same time.

IDEALLY I don't want to use the main receive micromite to send a "transmit" signal to the remote units as it will be doing it's own thing and the receptioon will be done using interrupts - ie it receives an interrupt and listens for the data then carries on with what it was doing.

Hope that made sense

For those that don't know, the HC-12 is a 433(ish) Mhz transmitter/reciever that is basically as remote serial link.
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:43am 04 Apr 2016
Copy link to clipboard 
Print this post

Just a Wild Guess at what might work without thinking too hard.

You won't be able to have all the slaves on the same channel at the same time.
Think it would be a bit like an overloaded CB radio network.

Something like implementing a TDMA System might work.

The HS-12's on the remote Mites could be powered by a Digital I/O Pin, & each only powered up for its given time slot.

IE, 6 remote Mites;

1st active 0-5 seconds of each minute.
2nd active 5-10 seconds of each minute.
...
...
6th active 25-30 seconds of each minute.
1st active 30-35 seconds of each minute.
...
...

Would require all clocks to be kept in sync and not sure what other issues it might present with the master disconnecting & reconnecting repeatedly.

Out of curiosity, how quickly do the HC-12's connect & do they spit any data out on connection?

Cheers

Phil
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 02:30pm 04 Apr 2016
Copy link to clipboard 
Print this post

send each with a byte to identify the sender and a checksum.
If there is a checksum error caused by two sending at once, the master sends a 'please resend'
Each remote has a different wait period before re sending to prevent another collision.

Provided the remotes are sending at random intervals and not too frequently, you shouldn't have too many collisions.

Jim
VK7JH
MMedit
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2428
Posted: 02:55pm 04 Apr 2016
Copy link to clipboard 
Print this post

assign a 'name' to each remote micromite: for instance 'M1', 'M2', 'M3', etc.

set up the on code each of the remote micromites so that when it hears its own name, it responds immediately with a message containing the temperature.

now have the central micromite transmit each name string one at a time, with say 1 second gap between each. during those gaps the central micromite needs to listen for the response, if any.

this is called 'polling'.


cheers,
rob :-)
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 10:59pm 04 Apr 2016
Copy link to clipboard 
Print this post

I Like the polling idea, apart from it would mean the master micromite interupting it's program to send out the poll which is something I didn't really want it to do but not impossible.
The biggest downside is the remote ones would only be sending the temperature (data) one every 5 minutes or so and at all other times would be in sleep mode to conserve battery power - so the polling wouldn't work.

Phil23's idea would work IF I put a RTC on each micromite but it's increasing the cost/component count for something which is basically just a temp sensor (and all the clocks would have to be synchronised).

TassyJim Unfortunately I don't know enough about programming to know how to make them generate/send a checksum

It's a very good idea although I'm kinda guessing it would work like this-
If the master micromite got an interupt from it's HC-12 when one of the remotes transmitted and stopped the program it was running to "listen" it listened for a checksum and if it was wrong it sent a "please repeat" signal to the micromite that sent the signal?

Is that how it would work?
If it did that would be ideal, IF I could figure out how to do it
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 05:23am 05 Apr 2016
Copy link to clipboard 
Print this post

Been reading the manual and the WAKEUP command - I can't quite grasp this.

I "think" it means you can tell the micromite to sleep and it will stay asleep if no timer is set until it gets an input on a pin (high or low???)

Could the serial port be used as an input pin for this and how would you define it as such?

I mean get the Micromite to sleep and once it receives a signal on the serial port it wakes up and proceedes with it's program then sleeps till it gets the next "wakeup" signal

Would this work, and how could I define the pin to do this function as well as being a serial port pin (say COM 1 for example)

 
crez

Senior Member

Joined: 24/10/2012
Location: Australia
Posts: 152
Posted: 05:08pm 05 Apr 2016
Copy link to clipboard 
Print this post

The only pin that can wake the PIC is the 'wakeup' pin. Of course you can feed your serial to this pin as well as to the COM receive pin. I'm not sure the wakeup will be fast enuf to catch the first byte.

David
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 05:58pm 05 Apr 2016
Copy link to clipboard 
Print this post

First i would define a simple protocol.
Data with a header to identify the slave, followed by the data and a CRC.

The slave would send this to the master once it wakeups and collects it data.

I would not worry about a collision with another slave as this is hard to detect. Just check for correct reception of the message using the CRC. The master would need to NACK the message when it is corrupt. The slave would then delay somewhere between one to ten seconds before retrying.

Once it is acknowledged the slave can go back to sleep. Over time the slaves would get their own 'timeslot' automatically with only an very small change of collision.


Microblocks. Build with logic.
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 09:49pm 05 Apr 2016
Copy link to clipboard 
Print this post

Thanks Jean, I'll have to read up on how to generate a crc/checksum I think
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 10:06pm 05 Apr 2016
Copy link to clipboard 
Print this post

A simple check sum routine.
Each character ASCII value is added to the sum and we use the lower 8 bits.
The checksum is then added to the end of the string with CHR$()


DO
INPUT txt$
sum = chksum(txt$)
txt$ = txt$+CHR$(sum)
PRINT sum,txt$

LOOP


FUNCTION chksum(report$)
LOCAL n, ch$
chksum=0
FOR n = 1 TO LEN(report$)
ch$=MID$(report$,n,1)
chksum=chksum XOR ASC(ch$)
NEXT n
chksum = chksum MOD 256
'print chksum
END FUNCTION


JimEdited by TassyJim 2016-04-07
VK7JH
MMedit
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 11:04pm 05 Apr 2016
Copy link to clipboard 
Print this post

  lew247 said  Phil23's idea would work IF I put a RTC on each micromite but it's increasing the cost/component count for something which is basically just a temp sensor (and all the clocks would have to be synchronised).



Hi Lew,

I did consider the accuracy of the clocks, but am assuming the Slaves could request the time from the Master at a regular interval, hence needing only one RTC to keep them all syncronised.

Played with time a few nights back, was trying to come up with a way of using the Time$ & Date$ to set the RTC from the MM once it's time had been set by MM Edit,
rather than what I'm doing now, which is typing RTC SETTIME, & waiting for the laptop to tick over the minute before hitting Enter.

Cheers

Phil
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 12:04am 06 Apr 2016
Copy link to clipboard 
Print this post

Thanks both
TassyJim could you have a look at My Post HERE

and explain how I could incorporate the code you posted above please?

I can't figure out how to do it as I don't know how many characters to be expecting each time the temperature is sent, and to be honest being the newbie that I am, I can't figure out how I could do it.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025