Django iot data streaming into app

Yes, Django / Channels would work for this - but it’s not the only way to do it.

Have you worked your way through the Channels tutorial? That shows you how to set up a consumer that listens to a websocket. Your consumer can receive the websocket data and then save it into a Model.

However, since this appears to be a one-way communication - from the external device to Django - I’m not sure I would use that method.

Your other options include:

  • Writing a network service that listens on a port, allowing an external connection and data transmission. That service could be written as a custom Django admin command, allowing the service to save data in models.

  • Allow the external device to write directly to redis, and write a custom Django admin command to monitor that redis key, taking action when data appears.

I’ve actually done all three in different projects.

Also, depending upon the rate and quantity of data, you could just submit it as data through an API-type call. There’s no real polling involved.

But only you can make the decision of which approach to take, and what is going to work best is going to depend upon a variety of factors. (Number of devices supplying this data, size and frequency of data submissions, the capability and software constraints of the sending device, networking infrastructure and constraints, what you’re looking to do with the data after you have it, etc, etc, etc)

1 Like